]> granicus.if.org Git - postgresql/commitdiff
Don't wait for the commit record to be replicated if we wrote no WAL.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 17 Apr 2012 13:28:31 +0000 (16:28 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 17 Apr 2012 13:36:59 +0000 (16:36 +0300)
When using synchronous replication, we waited for the commit record to be
replicated, but if we our transaction didn't write any other WAL records,
that's not required because we don't even flush the WAL locally to disk in
that case. This lead to long waits when committing a transaction that only
modified a temporary table. Bug spotted by Thom Brown.

src/backend/access/transam/xact.c

index 7bdf38636b5ed7c7fbd8d7eb7b85f55d19fa2333..901fff059a1e9480e82179b8488d9663209f388f 100644 (file)
@@ -1141,7 +1141,8 @@ RecordTransactionCommit(void)
         * Note that at this stage we have marked clog, but still show as running
         * in the procarray and continue to hold locks.
         */
-       SyncRepWaitForLSN(XactLastRecEnd);
+       if (wrote_xlog)
+               SyncRepWaitForLSN(XactLastRecEnd);
 
        /* Reset XactLastRecEnd until the next transaction writes something */
        XactLastRecEnd.xrecoff = 0;