forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit985bd7d
committed
Support clean switchover.
In replication, when we shutdown the master, walsender tries to sendall the outstanding WAL records to the standby, and then to exit. Thisbasically means that all the WAL records are fully synced betweentwo servers after the clean shutdown of the master. So, afterpromoting the standby to new master, we can restart the stoppedmaster as new standby without the need for a fresh backup fromnew master.But there was one problem so far: though walsender tries to send allthe outstanding WAL records, it doesn't wait for them to be replicatedto the standby. Then, before receiving all the WAL records,walreceiver can detect the closure of connection and exit. We cannotguarantee that there is no missing WAL in the standby after cleanshutdown of the master. In this case, backup from new master isrequired when restarting the stopped master as new standby.This patch fixes this problem. It just changes walsender so that itwaits for all the outstanding WAL records to be replicated to thestandby before closing the replication connection.Per discussion, this is a fix that needs to get backpatched rather thannew feature. So, back-patch to 9.1 where enough infrastructure forthis exists.Patch by me, reviewed by Andres Freund.1 parent4f14c86 commit985bd7d
1 file changed
+8
-4
lines changedLines changed: 8 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
30 |
| - | |
| 30 | + | |
| 31 | + | |
31 | 32 |
| |
32 | 33 |
| |
33 | 34 |
| |
| |||
1045 | 1046 |
| |
1046 | 1047 |
| |
1047 | 1048 |
| |
1048 |
| - | |
| 1049 | + | |
| 1050 | + | |
1049 | 1051 |
| |
1050 | 1052 |
| |
1051 | 1053 |
| |
1052 | 1054 |
| |
1053 | 1055 |
| |
1054 | 1056 |
| |
1055 | 1057 |
| |
1056 |
| - | |
| 1058 | + | |
| 1059 | + | |
1057 | 1060 |
| |
1058 | 1061 |
| |
1059 | 1062 |
| |
| |||
1728 | 1731 |
| |
1729 | 1732 |
| |
1730 | 1733 |
| |
1731 |
| - | |
| 1734 | + | |
| 1735 | + | |
1732 | 1736 |
| |
1733 | 1737 |
| |
1734 | 1738 |
| |
|
0 commit comments
Comments
(0)