]> granicus.if.org Git - postgresql/commitdiff
Before exiting walreceiver, fsync() all the WAL received.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 17 Jan 2011 10:22:24 +0000 (12:22 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 17 Jan 2011 10:27:35 +0000 (12:27 +0200)
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.

src/backend/replication/walreceiver.c

index d257caf913df8d19e2e88802cf48564aa12ad95a..7005307dc250da66e88e03d7da05ece6734e0e48 100644 (file)
@@ -324,6 +324,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);