mirror of
https://github.com/postgres/postgres.git
synced 2026-04-24 23:57:18 -04:00
Wake WALSender to reduce data loss at failover for async commit.
WALSender now woken up after each background flush by WALwriter, avoiding multi-second replication delay for an all-async commit workload. Replication delay reduced from 7s with default settings to 200ms, allowing significantly reduced data loss at failover. Andres Freund and Simon Riggs
This commit is contained in:
parent
5c3532876f
commit
16222f32ed
1 changed files with 9 additions and 0 deletions
|
|
@ -2168,6 +2168,7 @@ XLogBackgroundFlush(void)
|
|||
{
|
||||
XLogRecPtr WriteRqstPtr;
|
||||
bool flexible = true;
|
||||
bool wrote_something = false;
|
||||
|
||||
/* XLOG doesn't need flushing during recovery */
|
||||
if (RecoveryInProgress())
|
||||
|
|
@ -2236,10 +2237,18 @@ XLogBackgroundFlush(void)
|
|||
WriteRqst.Write = WriteRqstPtr;
|
||||
WriteRqst.Flush = WriteRqstPtr;
|
||||
XLogWrite(WriteRqst, flexible, false);
|
||||
wrote_something = true;
|
||||
}
|
||||
LWLockRelease(WALWriteLock);
|
||||
|
||||
END_CRIT_SECTION();
|
||||
|
||||
/*
|
||||
* If we wrote something then we have something to send to standbys also,
|
||||
* otherwise the replication delay become around 7s with just async commit.
|
||||
*/
|
||||
if (wrote_something)
|
||||
WalSndWakeup();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue