postgres.git / summary / log / commit / refs
commit 2c8a4e9be2730342cbca85150a2a9d876aa77ff6
Author: Simon Riggs <simon@2ndQuadrant.com>
Date: Thu Jun 07 18:22:47 2012 +0000
First released in: 9.2.0, REL9_0_STABLE (reverted before release), 9.1.5
Reverted by: da6bb58ed9da (in 9.0.9)
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
src/backend/access/transam/xlog.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index d3650bdf051..0f2678cfda0 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -2271,6 +2271,13 @@ XLogBackgroundFlush(void)
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;
}
[parent: b50991eedb45]