-
Notifications
You must be signed in to change notification settings - Fork 21
[Postgres] Resumeable initial replication #150
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
🦋 Changeset detectedLatest commit: 0f0f3ca The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
5b8bb9b
to
50096e0
Compare
Results from testing a table with 4M records from Supabase: Replicates for 5 minutes at a time; then takes 6 minutes to time out. Replication attempts finished at this number of rows replicated:
There is generally 11 minutes between the start of each batch. Total time to replicate was 56 minutes. Future work:
|
This removes reliance on a Postgres snapshot for initial replication, allow replication to be resumed after being interrupted.
Initial replication could be interrupted because of any of the following reasons, among others:
This allows keeping existing progress in those cases, and gracefully resume replication.
Currently this can efficiently skip tables already replicated completely when resuming. Tables partially replicated will skip persistence of rows already replicated, but does still have a lot of overhead for reading those rows. On my machine with a local setup, it takes around 80ms to persist a new batch, and 20ms to skip a batch previously replicated (batch size = 2000).
In theory, this limits us to an absolute max of 30 million rows per table if cursors time out after 5 minutes. In practice there are other overheads, so this will probably support closer to 10 million rows with that timeout. Without the 5-minute timeout, there is no hard limit.