diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2008-10-20 19:18:18 +0000 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2008-10-20 19:18:18 +0000 |
commit | 06da3c570f21394003fc392d80f54862f7dec19f (patch) | |
tree | 2e4c5dc1cb78d87e12fc1495b084bfaf5e69e737 /src/backend/access/transam/twophase.c | |
parent | 3afffbc902f16f5b9abd2464a2bbc17d9bc63316 (diff) |
Rework subtransaction commit protocol for hot standby.
This patch eliminates the marking of subtransactions as SUBCOMMITTED in pg_clog
during their commit; instead they remain in-progress until main transaction
commit. At main transaction commit, the commit protocol is atomic-by-page
instead of one transaction at a time. To avoid a race condition with some
subtransactions appearing committed before others in the case where they span
more than one pg_clog page, we conserve the logic that marks them subcommitted
before marking the parent committed.
Simon Riggs with minor help from me
Diffstat (limited to 'src/backend/access/transam/twophase.c')
-rw-r--r-- | src/backend/access/transam/twophase.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index b86bdc36677..d24ea6b2a10 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.45 2008/08/11 11:05:10 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.46 2008/10/20 19:18:18 alvherre Exp $ * * NOTES * Each global transaction is associated with a global transaction @@ -1745,9 +1745,7 @@ RecordTransactionCommitPrepared(TransactionId xid, XLogFlush(recptr); /* Mark the transaction committed in pg_clog */ - TransactionIdCommit(xid); - /* to avoid race conditions, the parent must commit first */ - TransactionIdCommitTree(nchildren, children); + TransactionIdCommitTree(xid, nchildren, children); /* Checkpoint can proceed now */ MyProc->inCommit = false; @@ -1822,8 +1820,7 @@ RecordTransactionAbortPrepared(TransactionId xid, * Mark the transaction aborted in clog. This is not absolutely necessary * but we may as well do it while we are here. */ - TransactionIdAbort(xid); - TransactionIdAbortTree(nchildren, children); + TransactionIdAbortTree(xid, nchildren, children); END_CRIT_SECTION(); } |