Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 - fix an issue where we would not converge in certain P2P scenarios #114

Merged
merged 16 commits into from
Dec 22, 2022

Conversation

tantaman
Copy link
Collaborator

When we switch from the vector clock to lamport clock design, we ended up conflating two concepts:

  1. the clock of the database used to track missed changes
  2. the clock of a column used to do merging

The original vector clock approach kept a version per column independent of the clock of the database.

When we merged the two ideas we created a situation where any time a merge changed a column value, we would set the clock of that column not to the winner's version but to MAX(winner_version, crsql_nextdbversion())

This would cause a column to have its version number re-assigned.

Example:

Peer P @ db_version 100:
[id1, A, v_6]

Peer Q:
[id1, B, v_7]

merging Q to P would put P in this state:

[id1, B, v_100]

Making id1,B look much newer than it ought to be.

which is ok (at least from a convergence perspective, maybe not user expectation perspective) in a client-server sync but not in p2p sync. This would cause state results to differ based on which peers sync with which first and require many rounds of messages to converge. When optimizing to "not sync self sourced changes" this can hit cases of non-convergence.

@tantaman tantaman merged commit 22ff27f into main Dec 22, 2022
tantaman added a commit that referenced this pull request Dec 22, 2022
@tantaman tantaman deleted the version-fixup branch January 4, 2023 19:48
tantaman added a commit that referenced this pull request Sep 5, 2023
🐛 - fix an issue where we would not converge in certain P2P scenarios
tantaman added a commit that referenced this pull request Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant