mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
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:
parent
a08363d70c
commit
1435a8554c
@ -323,6 +323,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);
|
||||||
|
Loading…
Reference in New Issue
Block a user