supabase / pg_replicate

Build Postgres replication apps in Rust
Apache License 2.0
596 stars 22 forks source link

Fix the currently broken initial table copy for a newly added table #8

Open imor opened 6 months ago

imor commented 6 months ago

Currently when the replication binary starts it:

  1. Creates a snapshot.
  2. Reads all the tables in the publication.
  3. Makes an initial table copy of those tables which were not fully copied before.

This can result in different tables being copied with different snapshots which might result in inconsistent data. E.g. this happens in the following scenario:

  1. The publication contains table1 which has been copied.
  2. The replication process stops.
  3. table2 is added to the publication.
  4. The replication process starts.