Core: Fail concurrent replace transaction commits#2
Merged
Conversation
Replace commits now validate that underlying table metadata is unchanged since the replace started after refresh(); otherwise commit fails with CommitFailedException rather than overwriting concurrent updates (apacheGH-16232). Includes UpdateRequirements alignment, CatalogTests and Spark concurrent replace expectations, new TestReplaceTableSafety coverage, and hasMessageContaining("replace transaction") assertions for Checkstyle.
d13a3eb to
d91dd14
Compare
Fix the Test cases to align with the replace transaction concurrency. authored-by : shivakumar shivampeta
d91dd14 to
d99b2fb
Compare
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.
Summary
Fixes apache#16232.
This change prevents
REPLACE TABLEtransactions from silently overwriting concurrent committed table changes. If table metadata changes after a replace transaction starts, the replace transaction now fails withCommitFailedExceptioninstead of committing stale metadata.Problem
Before this change,
replaceTransaction()could overwrite concurrent commits without conflict detection. This affected concurrent:The root problem was that replace transactions refreshed the underlying table state but still committed the stale replacement metadata built when the transaction started. In addition, replace-table update requirements skipped several optimistic concurrency checks.
This allowed committed changes to disappear silently.
Changes
BaseTransaction.commitReplaceTransactionto fail if the table metadata changed since the replace transaction started.UpdateRequirements.forReplaceTableto use the same optimistic concurrency checks as ordinary table updates.TestReplaceTableSafety.Why this fixes the issue
A replace transaction now compares the original base metadata with the latest table metadata after refresh. If another writer committed in between, the replace transaction fails before committing stale metadata.
This prevents stale replace metadata from overwriting committed schema, property, snapshot, or data changes.
For REST-style commits,
UpdateRequirements.forReplaceTablenow emits normal optimistic concurrency requirements, so server-side validation can also reject conflicting replace commits.Testing
Ran: