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.
This commit is contained in:
Heikki Linnakangas 2011-01-17 12:22:24 +02:00
parent e0c274679c
commit 34ef02b4d4

View 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);