]> granicus.if.org Git - postgresql/commitdiff
Wake WALSender to reduce data loss at failover for async commit.
authorSimon Riggs <simon@2ndQuadrant.com>
Thu, 7 Jun 2012 18:22:47 +0000 (19:22 +0100)
committerSimon Riggs <simon@2ndQuadrant.com>
Thu, 7 Jun 2012 18:22:47 +0000 (19:22 +0100)
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

index d3650bdf051e7d34a6d194c500ef4b01be64baf4..0f2678cfda04a750d436d0eb1a2d7632ba2d5b57 100644 (file)
@@ -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;
 }