Closed yann-achard closed 3 years ago
Hey,
it is non-deterministic, at least going by the documentation Conflicting Changes.
It references your case directly
If users concurrently insert or delete items in a list (or characters in a text document), Automerge preserves all the insertions and deletions. If two users concurrently insert at the same position, Automerge will arbitrarily place one of the insertions first and the other second, while ensuring that the final order is the same on all nodes.
Kind regards, Nick
Hi @yann-achard, in general it's non-deterministic, but in this particular example it happens to be deterministic. The two concurrent insertions of '1'
and '2'
at the beginning of the array are ordered by the operation IDs of those insertion operations. Operation IDs consist of a per-actor counter followed by the ID of the actor that generated them. In this case, the operation doc.a.deleteAt(0, 1)
will have the same counter value as the operation doc.a.insertAt(0, '2')
, but the operation doc.a.insertAt(0, '1')
will have a higher counter value because it is preceded by a delete operation. Therefore, the insertion of '1'
(with the higher counter) will always be ordered before the insertion of '2'
(with the lower counter).
If you remove the line doc.a.deleteAt(0, 1)
, or if you add the same delete operation before doc.a.insertAt(0, '2')
, then the two insertion operations should have the same counter, and thus the merged outcome should become nondeterministic because they are now being ordered by actorId.
Thank you @ept and @DUG-nick. I was able to reproduce the nondeterminism by adding an operation before doc.a.insertAt(0, '2')
as described.
Hello. I am testing some of the corner case resolutions of various DDSes and Automerge seems to behave unexpectedly in this specific case:
Other DDSes I have tried this on deterministically produce the merge state
['2', '1']
. Those are:Is the outcome in Automerge in fact non-deterministic and I just haven't managed to trigger the other outcome (is there a reliable way to do that?)?
Am I wrong in expecting the outcome to be
['2', '1']
for Automerge?Thank you!