Hi Team,

Let us say we have a Master (M1) and a Slave (S1) in replication using
Streaming Replication.

I stopped all my writes from Application and i switched a WAL and made sure
it is replicated to Slave.
I have then shutdown M1. And ran a promote on S1.
Now S1 is my new Master with a new timeline.

Now, in order to let M1 replicate changes from S1 (Master) as a Slave, i am
able to succeed with the following approach.

Add recovery_target_timeline = 'latest' and then have the appropriate
entries such as primary_conninfo, standby_mode in the recovery.conf and
start the M1 using pg_ctl.

I see that it M1 (Old Master) is able to catch up with S1 (New Master). And
replication is going fine.
Have you ever faced or think of a problem with this approach ?

Points to note are :
1. Master was neatly SHUTDOWN after shutting down writes. So, it has not
diverged. (If it is diverged, i would of course need a pg_rewind like
approach).
2. It was a planned switchover. During this entire process, there are no
writes to M1 (before Switchover) or S1 (after promote).
3. timeline history file is also accessible to the Old Master (M1) after S1
was promoted. No transactions, so no WALs generated, may be 1 or 2
considering timeout, etc.

It looks like a clean approach, but do you think there could be a problem
with this approach of rebuilding Old Master as a Slave ? Is this approach
still okay ?

Thanks,
Avinash Vallarapu.

Reply via email to