2ndQuadrant / pglogical

Logical Replication extension for PostgreSQL 15, 14, 13, 12, 11, 10, 9.6, 9.5, 9.4 (Postgres), providing much faster replication than Slony, Bucardo or Londiste, as well as cross-version upgrades.

Home Page:http://2ndquadrant.com/en/resources/pglogical/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to tell pglogical to start at a specific lsn in the wal?

ApproximateIdentity opened this issue · comments

I'll describe a simplified version of the process to be concrete.

  1. Create a primary server as initdb -D ./primary, set it's wal_level to logical and start it up.
  2. Create a bunch of tables, insert data, etc.
  3. Reserve a replication slot in some way (the main purpose being to make sure the wal is not garbage collected).
  4. Stop the server and copy the directory like cp -r ./primary ./secondary. Start up both servers (on different ports).
  5. Assume that data has kept writing to the primary after the replication slot was reserved so that the primary has data that the secondary does not have, but also assume the wal has this data preserved. Assume that nothing else like schemas have changes.

Given that setup, I would like to get the secondary caught up with the primary. The secondary is a straight copy so by looking at how far it has gotten in the wal, I should be able to see where in the primary's wal to start replicating. Since the first replication slot has kept the wal from being garbage collected, the data really should be there. So then my question becomes, is it possible to start the replication from that location?

I feel like information theoretically this shouldn't be a problem, but obviously postgres doesn't need to fit my idealized mental model. Is something like this possible with pglogical in some way?

Thanks for any help!