[#12452] improvement(core): add OCC for catalog writes - #12455
Draft
yuqi1129 wants to merge 2 commits into
Draft
Conversation
yuqi1129
force-pushed
the
feat/12342-occ-catalog
branch
from
August 13, 2026 07:41
2b3ccfa to
af7cbad
Compare
Advance the metalake OCC version on every alter and guard alter and delete with a compare-and-set on the observed version, classifying a failed CAS as either a stale conflict or a missing entity. Keep the metalake root CAS and the non-empty check or the cascade cleanup inside one database transaction. A cascade locks the catalog rows first, then compare-and-set deletes descendant catalogs and schemas with their observed identifier-and-version pairs, so a concurrent child write is reported instead of silently dropped. Also add the shared OptimisticLockException factories used by the follow-up catalog and schema changes.
Advance the catalog OCC version on every alter and guard alter and delete with a compare-and-set on the observed version, classifying a failed CAS as either a stale conflict or a missing entity. Protect catalog creation with a shared lock on the parent metalake row on MySQL and PostgreSQL, without changing the parent version, so a catalog can no longer be created below a metalake that is being dropped. H2 uses an exclusive lock because it has no shared row-lock syntax. Keep the catalog CAS and the non-empty check or the cascade cleanup inside one database transaction, and CAS-delete descendant schemas with their observed identifier-and-version pairs.
yuqi1129
force-pushed
the
feat/12342-occ-catalog
branch
from
August 13, 2026 08:07
af7cbad to
42a1aed
Compare
Code Coverage Report
Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Add database-backed optimistic concurrency control and transaction boundaries for catalog writes.
Rebased on current
main(on top of #12374). Second of three PRs replacing #12350. Stacked on the metalake PR; review the top commit only.Why are the changes needed?
Managed catalog operations previously consisted of multiple independent reads and writes. Concurrent alter, create, and drop requests could overwrite newer metadata, create a catalog below a metalake that was being deleted, or run partial cascade cleanup.
Fix: #12452
Does this PR introduce any user-facing change?
Concurrent catalog version conflicts are reported as HTTP 409. If the observed entity was deleted or renamed away, alter reports not found and drop preserves its idempotent false result.
How was this patch tested?
./gradlew :core:test :core:javadoc -PskipITs(H2)TestCatalogMetaService,TestCatalogManager,TestPOConverters.-PskipDockerTests=false).