Repository navigation
[WIP] Replace transactions rebase onto refreshed metadata - #15904
smaheshwar-pltr wants to merge 6 commits into
Conversation
18a4607 to
0f26d6f
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
0f26d6f to
8e54050
Compare
8e54050 to
1eac286
Compare
1eac286 to
009f2a7
Compare
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
|
not stale |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
|
not stale |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
|
not stale |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
|
This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
Supersedes #15092.
Motivation
There are a few issues related to table replaces.
BaseTransaction.commitReplaceTransaction()does not re-apply replacement and transaction updates onto refreshed metadata. When concurrent changes occur, the transaction therefore commits stale metadata.When a
REPLACEtransaction commits after concurrent changes (appends, snapshot expiration, other replaces), it overwrites those changes with stale metadata. This can lead to snapshot history loss, and concurrent snapshot expiration can even cause table corruption. (#15090)V3 tables require that
snapshot.first-row-id>=table.next-row-idwhen adding a snapshot. The snapshot'sfirst-row-idis set frombase.nextRowId()when the snapshot is produced.With REST catalogs, updates are sent to the server which are generally applied to the server's current metadata. If a concurrent commit advanced the server's
next-row-id, the snapshot'sfirst-row-id(based on stale metadata) will be behind:This is returned as
CommitFailedExceptionso the client can retry, butcommitReplaceTransactionretries the same stalecurrent— the snapshot still has the oldfirst-row-id, so it fails every time. Therefore, I believe that in V3, any concurrent snapshot change in general (append, compaction, other replace) causes the replace to fail entirely. (#15905)Less severe, but there are currently behaviour differences in concurrent replaces for REST vs non-REST catalogs due to this. E.g. for REST catalogs, properties are sent as a
SetPropertiesdelta and the server generally merges them viaputAll, so concurrent property additions that have succeed survive a concurrent table replace. For non-REST catalogs though, they don't as the fullTableMetadataobject is committed directly, so the stalecurrentoverwrites all concurrent property changes.This PR
This PR unifies
commitReplaceTransactionandcommitSimpleTransactioninto a singlecommitWithRetry()method that refreshes metadata and re-applies pending updates before committing.The
startmetadata (the initialbuildReplacementresult) is stored onBaseTransactionso the replacement can be rebuilt against refreshed metadata viastartingMetadataFor(). AvalidateFieldIdscheck ensures that concurrent schema changes haven't caused field ID reassignment, which would make data files written during the transaction unreadable.Also: in
RESTTableOperations, thereplaceBasefield used before to generate requirements is removed — requirements are now generated frombaseand kept in sync viaapplyUpdates.