yuqi1129 opened a new pull request, #12455: URL: https://github.com/apache/gravitino/pull/12455
### What changes were proposed in this pull request? Add database-backed optimistic concurrency control and transaction boundaries for catalog writes. - Advance the catalog OCC version on every alter, and guard alter and drop with a compare-and-set on the observed version, classifying a failed CAS as either a stale-version conflict or an already-missing entity. - Protect catalog creation with a shared lock on the parent metalake row on MySQL and PostgreSQL, without changing the parent version. H2 uses an exclusive lock because it has no shared row-lock syntax. - Keep the catalog CAS, the non-empty check or the cascade cleanup, and the change-log writes in one database transaction, and CAS-delete descendant schemas with their observed identifier-and-version pairs. - Discard the stale local cache entry when a drop loses the race to another server, so the drop stays idempotent. 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) - New tests in `TestCatalogMetaService`, `TestCatalogManager`, `TestPOConverters`. - MySQL and PostgreSQL coverage is left to CI (`-PskipDockerTests=false`). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
