From: Heikki Linnakangas Date: Tue, 17 Apr 2012 13:28:31 +0000 (+0300) Subject: Don't wait for the commit record to be replicated if we wrote no WAL. X-Git-Url: http://git.postgresql.org/gitweb/-?a=commitdiff_plain;h=fe546f3da6a5ff1d879f587728f74ec457f0ee5f;p=users%2Frhaas%2Fpostgres.git Don't wait for the commit record to be replicated if we wrote no WAL. 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. --- diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index e22bdacbba..d8523f37b2 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -1168,7 +1168,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;