Repository navigation
fix(sync): keep local edits ahead of every clock this device has seen - #1542
Merged
Merged
Conversation
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.
Summary
An edit made right after a sync could lose to the very change it followed: last-writer-wins compares stamps, and this device stamped its edit with its own wall clock, which may be behind the other device's. Flow-Tube/flow-sync#38 now says what "hybrid logical clocks are persisted" means, and this implements it:
DeviceIdentitykeeps the highest physical time of any stamp this device has applied (clock_msin the existingsync_identitystore).editTime()returnsmax(now, that + 1).SyncChangeTrackerstamps every local edit and tombstone witheditTime(), and raises the mark whenever a merge settles.The wire format doesn't change. This covers FLOW-SYNC/1 sessions and the coming linked-devices sync alike.
Related issue
Part of #1075 (linked devices).
Change type
Validation
./gradlew :app:assembleGithubDebug: ok (on top of fix(sync): let sync remove a channel from a group #1543, which includes this commit)./gradlew :app:testGithubDebugUnitTest: 4570 passed, 46 skipped, 0 failed (same); newSyncChangeTrackerTest.an_edit_after_a_newer_peer_stamp_is_stamped_after_it./gradlew ktlintCheck: okTest device and Android version: none (JVM tests)
Risk and compatibility
One new key in the existing device-only
sync_identityDataStore. Flow Desktop ships the same rule in its own PR.