Repository navigation
Fix merges that lose an added object matching a later base object - #10629
Merged
Merged
Conversation
skshetry
force-pushed
the
saugat/fix/merge-added-key-matches-later-base
branch
from
November 30, 2026 14:39
0e65b14 to
1991f76
Compare
#10629) * graveler: test adding a key that matches a later base key One side adds key k2 with the identity of base key k3, and the other side deletes k3. The merge must keep k2 under every strategy, whichever side added it. The cases fail until the merge compares the base key with the key being merged. * graveler: keep an added key that matches a later base key Once one side of a merge has no records left, the merge walks the rest of the other side. It skipped a record whose identity matched the first base record at or after its key, taking it as unchanged on this side and deleted on the other. That base record can belong to a later key, so a newly added key was dropped without a conflict. A record is now skipped only when the base record has the same key. Fixes: #10627
skshetry
force-pushed
the
saugat/fix/merge-added-key-matches-later-base
branch
from
November 30, 2026 14:40
1991f76 to
0de0d0f
Compare
* graveler: test merges where both sides add the same key Source and dest each add key a with a different identity, and base holds only a later key b whose identity equals one side's a. A merge with no strategy must report a conflict, and a merge with a strategy must write the side that strategy favours. The cases fail until the merge compares the base key with the key being merged. * graveler: report a conflict when both sides add a key A merge looks up the first base record at or after the key it is merging, so the record can belong to a later key. When both sides added the same key with different identities, and that later base record had the identity of one side, the merge took the key as changed by the other side only. It wrote that side's value and reported no conflict, without consulting conflict resolvers or the merge strategy. The base record now counts as the base version only when its key equals the key being merged. Otherwise the key is new on both sides and goes to conflict handling. Merges of this shape that used to succeed now fail with "Conflict found" unless a strategy or resolver settles them. Fixes: #10559
skshetry
force-pushed
the
saugat/fix/merge-added-key-matches-later-base
branch
4 times, most recently
from
November 30, 2026 14:44
4fe9daf to
73054fd
Compare
AliRamberg
approved these changes
Nov 30, 2026
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 #10559
Closes #10627
Problem
A merge can silently lose data when a newly added object has the same content as the next object, in path order, of the merge base. Empty marker files such as
_SUCCESShit it most easily.Both branches add the same path with different content. The merge succeeds and keeps one side instead of reporting a conflict:
One branch adds an object and the other deletes the next base object. The merge drops the added object:
To find the base version of a path, the merge takes the first base entry at or after that path. In two places it compared only the content of that entry, not its path.
Solution
A base entry counts as the base version only when its path equals the path being merged. Otherwise the path is new.
Merges of the first shape used to succeed. They now fail with
Conflict found, unless a merge strategy settles them. Revert and cherry-pick use the same merge, so they change the same way.Testing
New unit tests cover both shapes, with source and destination swapped and under each merge strategy. They fail without the fix.
I also ran the reproductions against live servers built from
masterand from this branch:masterdevintomain["a"][]["a"]add aontodev["a"][]["a"]add b["a"][]["a"]conflictmerged without conflict, prefix/A = b'D'conflict🤖 Generated with Claude Code