0

I have a question: What happens if replication is configured from a primary Postgres server to a deviated standby server?

To explain more: Lets say I did a PITR restore from a 1-week-old backup on a new standby server, and Postgres started well after fetching then needed WALs from the archive server and having a legit valid checkpoint; so now the standby is in a point of 1-week old.

Then I configured the standby to have streaming WALs from the primary, which has been operating normally for this week since the backup was taken. What will happen considering they are not on the same point?

2
  • 1
    If the primary server has not retained the week of WAL files, how can it bring the week old copy up to a current state?
    – RonJohn
    Feb 15 at 10:40
  • Also, the primary server needs to know that it’s replicating to another server (usually via a replication slot). Does the primary know that it’s supposed to be replicating?
    – RonJohn
    Feb 15 at 10:44

1 Answer 1

2

The standby will connect to the primary and ask it for the WAL it needs to continue recovery. If the primary doesn't have that WAL any more (old WAL gets deleted during checkpoints), the primary will send the standby an error message and terminate the connection. The standby will remain in recovery mode, but won't be able to stream changes from the primary.

If you have restore_command in place, the standby will catch up and then continue replicating.

2
  • If the WALs cannot be found, won't the standby try to get it through the 'restore_command' parameter in the postgresql.conf file from the archive server ? Feb 15 at 14:35
  • That would work fine, and the standby would catch up. Feb 15 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.