0

I have the following environment: A postgres server (rhel8, postgresql v14) as master and another as standby. I need to do a maintenance task on the infrastructure and for this reason both vms need to be turned off, the task would not take much more than 20-30 minutes, my question is in the order in which the vms of the postgres environment can be turned off It is being replicated, if there is one or any recommendation. There is the possibility of turning off both almost at the same time, but I would also be evaluating the possibility of turning off the ESXi server (they are separated in different ESXi) where one of the two is (master or standby) in order to have the service still up (I know that in the case of the standby it would only be in reading mode) while the infra maintenance is carried out on that server and after turning on continue with the other. Does the order in which vms are shutdown impact the postgresql replication environment?

1 Answer 1

2

You can shutdown and restart primary and standby in any order you want; that won't cause a problem.

However, you could get into trouble if you keep the standby server down while data modifications continue on the primary server. In that case, the standby could fall behind so much that the primary doesn't have the required WAL for recovery any more. You can prevent that from happening if you use a replication slot, or you can allow the standby to recover by setting restore_command on the standby so that it can catch up from a WAL archive.

2
  • Thank you very much for your reply! So, it would be more prudent to stop the master first to avoid wal generation, perform maintenance on the infrastructure, with standby on, then turn off standby, perform maintenance on your infrastructure and when finished turn on/start standby first and then the master? Is that order correct? May 25, 2023 at 5:00
  • 1
    That is 100% safe, yes. May 25, 2023 at 5:14

Your Answer

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

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