Repository navigation
fix(table): reject concurrently added duplicate files in AddDataFiles and AddDataFilesByPath - #2678
Open
akritishakya wants to merge 9 commits into
Open
akritishakya wants to merge 9 commits into
akritishakya wants to merge 9 commits into
Conversation
…ilespath-adds-twice # Conflicts: # website/src/releases.md
laskoviymishka
self-requested a review
November 20, 2026 22:05
zeroshade
reviewed
Nov 23, 2026
zeroshade
left a comment
Member
There was a problem hiding this comment.
Thanks, the fix is correct. Doing the check in rebuildFn rather than in a validator makes sense: fast/merge append don't register validators, and newConflictContext would fail a rollback with ErrCommitDiverged. Checking live entries on the fresh parent handles rollback, expiry and add-then-delete correctly. Merged with main, go test -race ./table/ -run 'AddDataFiles|Duplicate|Concurrent' passes, and the three rejection tests fail with snapshot_producers.go and transaction.go reverted to main.
- Retry cost.
checkRemovedFilesdeliberately returns early for append producers so a retry doesn't re-read the parent's manifests, butcheckDuplicatePathsnow reads every data manifest of the fresh parent on each retry. Manifest files never change once written, and every manifest in the planned parent was already scanned by the staging-time duplicate check. So the check could skip manifests whose path is in the planned parent's manifest list and read only those added by concurrent commits. That stays correct after a rollback (the manifest set only shrinks) and after merge-append rewrites (rewritten manifests get new paths). Either way, the comment incheckRemovedFilesabout append producers skipping the scan should be updated. - nit: none of the new tests enable
commit.manifest-merge.enabled.appendSnapshotProducercan returnmergeAppend(), so one concurrent-duplicate case with it enabled would cover that producer. - nit:
duplicateCheckPathsholds the caller'ssetToAdd/setmap itself. Nothing changes it after staging, so this is safe, butmaps.Clonewould remove the coupling. - Question:
ReplaceDataFiles/ReplaceDataFilesWithDataFilesalso take caller-supplied paths. Do they have the same retry gap, or is that handled elsewhere?
Contributor
Author
|
@zeroshade Thanks for the review.
|
This branch has not been deployed
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.
Closes #2629
Problem
By default,
AddDataFilesandAddDataFilesByPathreject paths already in the table, but only against the snapshot the transaction was planned on. If another writer commits the same path first, a commit retry adds the file a second time and its rows are read twice. The same happens whenCommit()is called again after a failedCommit()that left the transaction committable.Fix
checkDuplicatePaths(aftercheckRemovedFiles), which fails the commit withErrDuplicateDataFiles, wrapped inErrTransactionUnusable, if any of the paths being added is a live data file in the new parent.WithoutDuplicateCheck()andignoreDuplicates=truealso disable this check.table.go,concurrent-writes.mdandreleases.md.Tests
New file
table/add_files_conflict_test.gocovers:Commit()(rejected)The tests that expect
ErrDuplicateDataFilesfail without this change.