Skip to content

Commit 1435a85

Browse files
committed
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.
1 parent a08363d commit 1435a85

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/backend/replication/walreceiver.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ WalRcvDie(int code, Datum arg)
323323
/* use volatile pointer to prevent code rearrangement */
324324
volatile WalRcvData *walrcv = WalRcv;
325325

326+
/* Ensure that all WAL records received are flushed to disk */
327+
XLogWalRcvFlush();
328+
326329
SpinLockAcquire(&walrcv->mutex);
327330
Assert(walrcv->walRcvState == WALRCV_RUNNING ||
328331
walrcv->walRcvState == WALRCV_STOPPING);

0 commit comments

Comments
 (0)