Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c8a4e9

Browse files
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
1 parent b50991e commit 2c8a4e9

File tree

1 file changed

+7
-0
lines changed
  • src/backend/access/transam

1 file changed

+7
-0
lines changed

src/backend/access/transam/xlog.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,13 @@ XLogBackgroundFlush(void)
22712271

22722272
END_CRIT_SECTION();
22732273

2274+
/*
2275+
* If we wrote something then we have something to send to standbys also,
2276+
* otherwise the replication delay become around 7s with just async commit.
2277+
*/
2278+
if (wrote_something)
2279+
WalSndWakeup();
2280+
22742281
return wrote_something;
22752282
}
22762283

0 commit comments

Comments
 (0)