Skip to content

[#12650] improvement(core): add OCC for fileset writes - #12656

Merged
jerryshao merged 7 commits into
apache:mainfrom
yuqi1129:feat/12650-occ-fileset
Aug 28, 2026
Merged

[#12650] improvement(core): add OCC for fileset writes#12656
jerryshao merged 7 commits into
apache:mainfrom
yuqi1129:feat/12650-occ-fileset

Conversation

@yuqi1129

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

  • Use current_version as the OCC token for fileset alter and direct delete.
  • Advance the version and write a complete fileset snapshot for every successful alter.
  • Execute the root fileset CAS before version and dependent-row writes in one transaction.
  • Distinguish concurrent version changes from deleted, renamed, or moved filesets.
  • Keep versions monotonic during overwrite and use the persisted fileset identity for version rows.
  • Add comments explaining transaction ordering, CAS checks, and conflict classification.
  • Add service and SQL provider tests for the OCC behavior.

This is a subtask of #12166 and follows the table OCC implementation in #12551.

Why are the changes needed?

Concurrent fileset writes could overwrite the winning version metadata, while a stale delete could remove data belonging to a newer fileset version. Overwrite could also reset the OCC version.

Fix: #12650

Does this PR introduce any user-facing change?

Stale fileset writes now fail with the existing optimistic-lock or not-found response instead of overwriting newer metadata. No API or property is added.

How was this patch tested?

  • Ran the Fileset service, converter, and SQL provider tests on H2.
  • Ran :core:check -PskipITs -PskipDockerTests=true.
  • Ran Spotless and git diff --check.
  • MySQL and PostgreSQL execution was attempted, but the local database containers failed during connection setup before the test cases ran.

Copilot AI lite review requested due to automatic review settings August 26, 2026 14:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

Code Coverage Report

Overall Project 68.49% +0.59% 🟢
Files changed 76.68% 🟢

Module Coverage
aliyun 19.74% 🔴
api 52.6% +0.34% 🟢
authorization-common 85.96% 🟢
authorization-ranger 4.38% 🔴
aws 53.54% 🟢
azure 32.1% 🔴
catalog-common 9.9% 🔴
catalog-fileset 80.27% +12.3% 🟢
catalog-glue 69.24% 🟢
catalog-hive 82.96% 🟢
catalog-jdbc-common 45.69% 🟢
catalog-jdbc-doris 82.44% 🟢
catalog-jdbc-mysql 79.33% 🟢
catalog-jdbc-postgresql 83.39% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 76.99% 🟢
catalog-lakehouse-generic 60.55% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.86% 🟢
catalog-lakehouse-paimon 84.26% 🟢
catalog-model 77.99% 🟢
cli 44.48% 🟢
client-java 77.92% -2.52% 🟢
common 55.74% -0.19% 🟢
core 83.61% -0.27% 🟢
filesystem-hadoop3 76.45% 🟢
flink 0.0% 🔴
flink-common 50.29% 🟢
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-auth 68.0% 🟢
hadoop-common 17.84% 🔴
hive-metastore-common 53.4% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 64.75% 🟢
iceberg-rest-server 75.61% 🟢
idp-basic 85.98% 🟢
integration-test-common 0.0% 🔴
jobs 62.92% 🟢
lance-common 32.72% -2.88% 🔴
lance-rest-server 64.78% -8.51% 🟢
lineage 53.02% 🟢
optimizer 83.17% 🟢
optimizer-api 21.95% 🔴
server 88.04% -0.68% 🟢
server-common 80.35% +2.19% 🟢
spark 28.57% 🔴
spark-common 48.92% 🟢
tencent 69.84% 🟢
trino-connector 47.44% 🟢
Files
Module File Coverage
api SchemaChange.java 91.67% 🟢
CatalogChange.java 69.57% 🟢
catalog-fileset FilesetCatalogOperations.java 81.99% 🟢
client-java DTOConverters.java 54.64% 🔴
common CatalogUpdateRequest.java 60.0% 🟢
SchemaUpdateRequest.java 0.0% 🔴
core RelationalEntity.java 100.0% 🟢
DefaultMapperPackageProvider.java 100.0% 🟢
FilesetMetaBaseSQLProvider.java 100.0% 🟢
FilesetMetaPostgreSQLProvider.java 100.0% 🟢
MetalakeMetaService.java 99.32% 🟢
TagMetaService.java 98.51% 🟢
FilesetMetaSQLProviderFactory.java 96.67% 🟢
FilesetMetaService.java 93.98% 🟢
OperationDispatcher.java 91.27% 🟢
FilesetVersionSQLProviderFactory.java 90.91% 🟢
FilesetVersionBaseSQLProvider.java 90.91% 🟢
POConverters.java 88.32% 🟢
TagMetaSQLProviderFactory.java 88.0% 🟢
TagMetaBaseSQLProvider.java 86.67% 🟢
FilesetOperationDispatcher.java 82.86% 🟢
JDBCBackend.java 81.56% 🟢
SchemaOperationDispatcher.java 80.08% 🟢
RelationalEntityStore.java 76.33% 🟢
CatalogManager.java 71.25% 🟢
SupportsRelationOperations.java 70.0% 🟢
ManagedSchemaOperations.java 29.2% 🔴
RelationalBackend.java 20.0% 🔴
EntityStore.java 18.18% 🔴
FilesetMetaMapper.java 0.0% 🔴
FilesetVersionMapper.java 0.0% 🔴
TagMetaMapper.java 0.0% 🔴
lance-common NamespaceWrapper.java 96.0% 🟢
LanceConfig.java 94.74% 🟢
GravitinoLanceNameSpaceOperations.java 1.38% 🔴
ObjectIdentifier.java 0.0% 🔴
lance-rest-server LanceNamespaceOperations.java 88.37% 🟢
LanceRESTService.java 0.0% 🔴
server GravitinoInterceptionService.java 70.4% 🟢
server-common JcasbinAuthorizer.java 87.72% 🟢

… writes

- FilesetCatalogOperations.dropFileset now removes the metadata before
  the storage locations. The metadata delete is the step that can be
  rejected on a concurrent alter, and deleting the files first left the
  data gone while the surviving fileset row still advertised it.
- An alter starts above every snapshot the fileset still owns. A fileset
  written before the version reset was fixed can carry version rows above
  the version its metadata row records, and rebuilding one of those
  collided with uk_fid_ver_sto_del on every alter.
- The overwrite that keeps the persisted fileset ID now rewrites the
  stored gravitino.identifier property to that ID, so the version
  snapshot no longer disagrees with fileset_meta.
@yuqi1129 yuqi1129 self-assigned this Aug 27, 2026

@jerryshao jerryshao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review pass on the OCC changes. Two correctness concerns around orphaned storage on drop, plus a few smaller efficiency/style notes inline.

… OCC

- dropFileset no longer fails the drop when a storage location cannot be
  removed. The metadata is already gone at that point, so rethrowing left
  the caller with a failed drop it could never retry and files nothing
  refers to any more.
- The overwrite path applies the same version floor as the alter path.
  It derived the next version from the metadata row alone, which for a
  legacy fileset rewrote a stored snapshot instead of adding one.
- RelationalEntityStore.put invalidates instead of caching on overwrite,
  because the database decides the identity and version of an overwritten
  row and the copy handed in can disagree with it.
- Noted why the boolean returned by store.delete is still meaningful in
  dropFileset.
- deleteAndGet only treats a NoSuchEntityException from the delete itself
  as "nothing to delete". The catch also covered the change log, the cast
  and the cleanup callback, so a failure there was reported to the caller
  as a fileset that never existed while the delete was rolled back.
- The default deleteAndGet refuses a post-delete action instead of running
  it after the commit, which is the opposite of what the contract promises
  and what dropFileset relies on.
- A storage location that disappears between the existence check and the
  delete no longer fails the drop; the filesystem returning false for a
  path that is already gone is the outcome the drop wanted.
- filesetWriteFailure reports a conflict, not a missing fileset, when the
  name the caller used is now held by a different fileset.
- Documented the trade-offs the review called out: the storage delete runs
  inside the metadata transaction, every alter writes a version snapshot,
  and the upsert depends on current_version being assigned last.
@jerryshao
jerryshao merged commit 1573100 into apache:main Aug 28, 2026
41 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Subtask] Implement version-CAS OCC for fileset

3 participants