pgsql: Support clean switchover. - Mailing list pgsql-committers

From Fujii Masao
Subject pgsql: Support clean switchover.
Date
Msg-id E1UrWwA-0004LR-D2@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Support clean switchover.

In replication, when we shutdown the master, walsender tries to send
all the outstanding WAL records to the standby, and then to exit. This
basically means that all the WAL records are fully synced between
two servers after the clean shutdown of the master. So, after
promoting the standby to new master, we can restart the stopped
master as new standby without the need for a fresh backup from
new master.

But there was one problem so far: though walsender tries to send all
the outstanding WAL records, it doesn't wait for them to be replicated
to the standby. Then, before receiving all the WAL records,
walreceiver can detect the closure of connection and exit. We cannot
guarantee that there is no missing WAL in the standby after clean
shutdown of the master. In this case, backup from new master is
required when restarting the stopped master as new standby.

This patch fixes this problem. It just changes walsender so that it
waits for all the outstanding WAL records to be replicated to the
standby before closing the replication connection.

Per discussion, this is a fix that needs to get backpatched rather than
new feature. So, back-patch to 9.1 where enough infrastructure for
this exists.

Patch by me, reviewed by Andres Freund.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/985bd7d49726c9f178558491d31a570d47340459

Modified Files
--------------
src/backend/replication/walsender.c |   12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)


pgsql-committers by date:

Previous
From: Fujii Masao
Date:
Subject: pgsql: Support clean switchover.
Next
From: Andrew Dunstan
Date:
Subject: pgsql: Properly dump dropped foreign table cols in binary-upgrade mode.