postgresqldatabase-replicationpostgresql-11

What happens with the old primary after a "pg_ctl promote" on a replica?


I have a PostgreSQL 11 streaming (ie. wal_type = replica) cascading replication scheme set up as follows:

db1 -> db2 -> db3

What happens to db1 and db3 if I execute a pg_ctl promote on db2?

Since falling back to the original primary after a failover to a replica is not trivial, I'm particularly concerned on keeping db1 unaffected so I can use it as an original primary backup if anything goes wrong with the promotion (and recreating db2 and db3 if necessary, even with some data loss that could be acceptable in my case).


Solution

  • When you execute pg_ctl promote on db2,first walreceiver process of db2 is terminated and second startup process will try to apply the wal files if there is some apply lag,after this db2 is promoted as new master.

    db1 will not get converted to replica of db2 automatically,you have to manually handle it.

    db3 is not effected in process of promoting db2.

    Refer below link for more information:-

    https://www.postgresql.org/docs/current/warm-standby-failover.html