Home > Enterprise >  Promoting a postgres slave to master node
Promoting a postgres slave to master node

Time:06-03

I have two postgresql 11.4 running as master and slave nodes.

I am inserting huge volume of data in master to see it get replicated on the slave. Trying to simulate the following case,

  • Insert huge data
  • pause_wal_replay on slave
  • wait for the wal files to get shipped to slave
  • resume_wal_replay on slave
  • promote immediately when there are multiple wal files waiting to be replayed

If a promote signal is issued at this point [ When there are multiple wal - already shipped and waiting to be replayed ], When will slave promote itself?

  1. After replaying all the existing wal files [ shipped and waiting to be replayed ] or

  2. Immediately after receiving promote signal. [ Without replaying the wal files waiting - causing data loss ? ]

If it is (1), what happens if the master node is still sending wal files and I try to promote the slave. Does it ignore the incoming wal and promote itself?

Hoping PG Experts can shed light on this.

PS : I'm issuing promote signal by creating a 'pg_failover_trigger' if its worth mentioning.

CodePudding user response:

When it is promoted, the standby server shuts down the WAL receiver process and recovers all remaining WAL it has. So we get the behavior from 1.

  • Related