Fix: Stop reapplying changes which have already been applied #101
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.
Co-authored by @beaucollins
This fix finds itself in the midst of a struggle to find the root cause
of the so-called "ghost-writing" or "infinite-duplication" bug. Under
certain relatively-rare and hard-to-reproduce circumstances we find a
given change reapplied as quickly as the library can communicate with
the server. This tends to destroy entities when transforming the change
against itself.
In this patch we're applying two techniques to prevent cycles in our
change update flow: stop applying any patch whose end version is below
our ghost's version; and make sure we ackwnoledge a queued change if
the server sends it back as a duplicate change.. If we have a newer
ghost than the change then it implies that the change has already been
applied. Likewise, if we submit a patch the server has already received
then we should flush any local buffers holding on to it.
These two changes will prevent a subset of possible ways that we can
trigger ghost-writing but it's unclear how significant that subset is
relative to all cases. We know that in some cases the local client
library continues to send changes to the server without updating its
local
sv
and it does not appear like this change will address thosecases.