Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 34ef02b

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 e0c2746 commit 34ef02b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/backend/replication/walreceiver.c

+3
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ WalRcvDie(int code, Datum arg)
324324
/* use volatile pointer to prevent code rearrangement */
325325
volatile WalRcvData *walrcv = WalRcv;
326326

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

0 commit comments

Comments
 (0)