-
Notifications
You must be signed in to change notification settings - Fork 101
feat: resume interrupted CoValues sync on restart #3320
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
Conversation
| peers?: Peer[]; | ||
| syncWhen?: SyncWhen; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer both params to be part of a single SyncConfig object, but didn't want to introduce a breaking change in the local node API
baa818d to
ea38b24
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
fd53d65 to
31f4e41
Compare
4aa45bb to
bde3fee
Compare
gdorsi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go!!!
| }), | ||
| ); | ||
| }, | ||
| ["unsyncedCoValues"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this API!
Co-authored-by: Guido D'Orsi <[email protected]>
Description
Currently, if CoValue sync is interrupted and the app is restarted, the sync process won't resume until the unsynced CoValue is loaded again.
This PR implements sync state tracking for CoValues in persistent storage, so that the sync process can be automatically resumed when the app restarts. Sync resumption is performed in batches, to avoid slowing down the performance of the app on startup.
Manual testing
Ran some performance testing in the browser to analyze the additional cost of tracking CoValue sync state. After applying some performance optimizations (persist pending sync updates in batches, minimize the number of times the sync state tracking callbacks are executed), managed to reduce it to what I consider a reasonable cost:
This measures the time it takes to create 10k tasks in the stress test app (which means creating 30k CoValues, including the tasks themselves, their group owners & their text content).
Tests
Checklist
Note
Introduces persisted tracking of unsynced
CoValues and automatic sync resumption after restart, focused on persistent server peers and batched writes for performance.UnsyncedCoValuesTrackerwith batched storage persistence, per-CoValue/global subscriptions, and flush ongracefulShutdownStorageAPIwithtrackCoValuesSyncState,getUnsyncedCoValueIDs,stopTrackingSyncStateunsyncedCoValuesstore, schema v5, CRUD inidbClient; SQLite: newunsynced_covaluestable + migrations and client methodsSyncManagerintegration:trackSyncState,resumeUnsyncedCoValues()(batched), only track persistent server peers, resume duringstartPeerReconciliationSyncStateManager.subscribeToPeerUpdatesnow keyed by(peerId, coValueId); related call sites updatedLocalNode/contexts acceptsyncWhenand propagate; logout/shutdown now awaits tracker flushWritten by Cursor Bugbot for commit 633321e. This will update automatically on new commits. Configure here.