[Bug] Fix data evolution self-merge ABA across rollback snapshot lineage - #9363
[Bug] Fix data evolution self-merge ABA across rollback snapshot lineage#9363zhang-arvin wants to merge 1 commit into
Conversation
|
Hi @zhang-arvin thanks for the changes the CI is failing, can you PTAL |
| new RuntimeException( | ||
| ErrorMessages.DATA_EVOLUTION_SNAPSHOT_LINEAGE_CONFLICT_MESSAGE)); | ||
| } | ||
| if (baseSnapshotUuid != null |
There was a problem hiding this comment.
Looks like Spark and Flink are using the single argument offloading causing the method to never get invoked. Would be better to capture and pass the UUID to the overloaded method.
|
Add snapshot UUID-based lineage validation to prevent staged row-ID partial updates from being applied to wrong snapshots after a rollback reuses the same numeric snapshot ID. Three-layer validation in checkForRowIdFromSnapshot: 1. Fail closed when latest snapshot ID < base snapshot ID (rollback deleted the update's base snapshot) 2. Detect missing base snapshot (race with concurrent cleanup) 3. ABA detection: compare base snapshot UUID with current snapshot UUID at the same ID (different lineage) The baseSnapshotUuid field is nullable for backward compatibility. Callers that don't pass UUID get existing behavior without the ABA protection. Closes apache#9352
e102180 to
bcfd450
Compare
|
Thanks for the review @ArnavBalyan @JingsongLi! Fixed the callers to pass snapshot UUID. Now BatchWriteBuilderImpl, DataEvolutionMergeIntoAction, and DataEvolutionDeleteSink all pass the UUID to rowIdCheckConflict. Added regression tests for ABA detection in ConflictDetectionTest. PTAL. |
|
@ArnavBalyan @JingsongLi I have verified locally that the code compiles successfully ( The PR changes include:
Could you re-trigger the CI when you have a chance? If the failures persist, I can investigate further. |
|
Java/Flink has switched to snapshot UUIDs, but Spark MERGE still calls |
What changes were proposed in this pull request?
Fix #9352: Data evolution self-merge validates staged row-ID partial updates using base snapshot ID only, not snapshot UUID. A rollback can delete newer snapshots, after which new commits reuse the same numeric snapshot IDs. This allows staged updates from old snapshots to be applied to different replacement snapshots (ABA problem).
Changes
DataEvolutionConflictDetection: AddbaseSnapshotUuidfield and UUID-based lineage validationlatestSnapshot.id() < rowIdCheckFromSnapshot(rollback deleted base)baseSnapshotUuidwith current snapshot UUID at same IDConflictDetection: AddsetRowIdCheckFromSnapshot(Long, String)UUID overloadFileStoreCommit/FileStoreCommitImpl: Add UUID overloadInnerTableCommit/TableCommitImpl: Add UUID overloadErrorMessages: AddDATA_EVOLUTION_SNAPSHOT_LINEAGE_CONFLICT_MESSAGEBackward Compatibility
The
baseSnapshotUuidfield is nullable. Callers that don't pass UUID continue to work with existing behavior (no ABA protection).Follow-up
Caller layers (Spark
PaimonSparkWriter, FlinkDataEvolutionMergeIntoAction,BatchWriteBuilderImpl) should be updated to pass the snapshot UUID for full ABA protection.Related issues