Commit 2c8a4e9b authored by Simon Riggs's avatar Simon Riggs

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 and often
much less, allowing significantly reduced data loss at failover.

Andres Freund and Simon Riggs
parent b50991ee
...@@ -2271,6 +2271,13 @@ XLogBackgroundFlush(void) ...@@ -2271,6 +2271,13 @@ XLogBackgroundFlush(void)
END_CRIT_SECTION(); 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();
return wrote_something; return wrote_something;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment