Skip to content
Snippets Groups Projects
Commit 34ef02b4 authored by Heikki Linnakangas's avatar Heikki Linnakangas
Browse files

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.
parent e0c27467
No related branches found
No related tags found
No related merge requests found
...@@ -324,6 +324,9 @@ WalRcvDie(int code, Datum arg) ...@@ -324,6 +324,9 @@ WalRcvDie(int code, Datum arg)
/* use volatile pointer to prevent code rearrangement */ /* use volatile pointer to prevent code rearrangement */
volatile WalRcvData *walrcv = WalRcv; volatile WalRcvData *walrcv = WalRcv;
/* Ensure that all WAL records received are flushed to disk */
XLogWalRcvFlush();
SpinLockAcquire(&walrcv->mutex); SpinLockAcquire(&walrcv->mutex);
Assert(walrcv->walRcvState == WALRCV_RUNNING || Assert(walrcv->walRcvState == WALRCV_RUNNING ||
walrcv->walRcvState == WALRCV_STOPPING); walrcv->walRcvState == WALRCV_STOPPING);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment