aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2011-01-17 12:22:24 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2011-01-17 12:29:15 +0200
commit1435a8554cd514d668a46c4f6b1e4a1e3bd30fd5 (patch)
treee83561c414a71587a7b4a9f0272132bd9b0c474d
parenta08363d70cb51f361c9525384e9f46a252fcd92e (diff)
downloadpostgresql-1435a8554cd514d668a46c4f6b1e4a1e3bd30fd5.tar.gz
postgresql-1435a8554cd514d668a46c4f6b1e4a1e3bd30fd5.zip
Before exiting walreceiver, fsync() all the WAL received.
Otherwise WAL recovery will replay the un-flushed WAL after walreceiver has exited, which can lead to a non-recoverable standby if the system crashes hard at that point.
-rw-r--r--src/backend/replication/walreceiver.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 06646ead94a..df4610732b1 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -323,6 +323,9 @@ WalRcvDie(int code, Datum arg)
/* use volatile pointer to prevent code rearrangement */
volatile WalRcvData *walrcv = WalRcv;
+ /* Ensure that all WAL records received are flushed to disk */
+ XLogWalRcvFlush();
+
SpinLockAcquire(&walrcv->mutex);
Assert(walrcv->walRcvState == WALRCV_RUNNING ||
walrcv->walRcvState == WALRCV_STOPPING);