Skip to content

Commit 463f151

Browse files
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.
1 parent 8431e29 commit 463f151

File tree

1 file changed

+13
-1
lines changed
  • src/backend/access/transam

1 file changed

+13
-1
lines changed

src/backend/access/transam/xact.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.290 2010/05/13 11:15:38 sriggs Exp $
13+
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.291 2010/05/13 11:39:30 sriggs Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1347,6 +1347,18 @@ RecordTransactionAbort(bool isSubXact)
13471347

13481348
(void) XLogInsert(RM_XACT_ID, XLOG_XACT_ABORT, rdata);
13491349

1350+
/*
1351+
* Report the latest async abort LSN, so that the WAL writer knows to
1352+
* flush this abort. There's nothing to be gained by delaying this,
1353+
* since WALWriter may as well do this when it can. This is important
1354+
* with streaming replication because if we don't flush WAL regularly
1355+
* we will find that large aborts leave us with a long backlog for
1356+
* when commits occur after the abort, increasing our window of data
1357+
* loss should problems occur at that point.
1358+
*/
1359+
if (!isSubXact)
1360+
XLogSetAsyncCommitLSN(XactLastRecEnd);
1361+
13501362
/*
13511363
* Mark the transaction aborted in clog. This is not absolutely necessary
13521364
* but we may as well do it while we are here; also, in the subxact case

0 commit comments

Comments
 (0)