diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2010-05-13 11:39:30 +0000 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2010-05-13 11:39:30 +0000 |
commit | 463f151a23242c531890589db3692077aadb05ca (patch) | |
tree | 5aa93239777921a314f88358bdaa842ae3f2462b /src | |
parent | 8431e296ea4cfc8dd30053f89b6970ef16ddbc61 (diff) | |
download | postgresql-463f151a23242c531890589db3692077aadb05ca.tar.gz postgresql-463f151a23242c531890589db3692077aadb05ca.zip |
Ensure that top level aborts call XLogSetAsyncCommit(). Not doing
so simply leads to data waiting in wal_buffers which then causes
later commits to potentially do emergency writes and for all forms
of replication to be potentially delayed without need or benefit.
Issue pointed out exactly by Fujii Masao, following bug report
by Robert Haas on a separate though related topic.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/transam/xact.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 91fbbd0be6b..8f2a3ed5e4f 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.290 2010/05/13 11:15:38 sriggs Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.291 2010/05/13 11:39:30 sriggs Exp $ * *------------------------------------------------------------------------- */ @@ -1348,6 +1348,18 @@ RecordTransactionAbort(bool isSubXact) (void) XLogInsert(RM_XACT_ID, XLOG_XACT_ABORT, rdata); /* + * Report the latest async abort LSN, so that the WAL writer knows to + * flush this abort. There's nothing to be gained by delaying this, + * since WALWriter may as well do this when it can. This is important + * with streaming replication because if we don't flush WAL regularly + * we will find that large aborts leave us with a long backlog for + * when commits occur after the abort, increasing our window of data + * loss should problems occur at that point. + */ + if (!isSubXact) + XLogSetAsyncCommitLSN(XactLastRecEnd); + + /* * Mark the transaction aborted in clog. This is not absolutely necessary * but we may as well do it while we are here; also, in the subxact case * it is helpful because XactLockTableWait makes use of it to avoid |