diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-08-22 02:41:58 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-08-22 02:41:58 +0000 |
commit | f009c316ba49857249611bc0d578c518c449879e (patch) | |
tree | 4fbab4d7068969dced2e698735407b1ffca38075 /src/backend/access/transam/transam.c | |
parent | 37d937ea2c062093887e6aa03879166b6db06900 (diff) | |
download | postgresql-f009c316ba49857249611bc0d578c518c449879e.tar.gz postgresql-f009c316ba49857249611bc0d578c518c449879e.zip |
Tweak code so that pg_subtrans is never consulted for XIDs older than
RecentXmin (== MyProc->xmin). This ensures that it will be safe to
truncate pg_subtrans at RecentGlobalXmin, which should largely eliminate
any fear of bloat. Along the way, eliminate SubTransXidsHaveCommonAncestor,
which isn't really needed and could not give a trustworthy result anyway
under the lookback restriction.
In an unrelated but nearby change, #ifdef out GetUndoRecPtr, which has
been dead code since 2001 and seems unlikely to ever be resurrected.
Diffstat (limited to 'src/backend/access/transam/transam.c')
-rw-r--r-- | src/backend/access/transam/transam.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index 34d281de587..2a32960f9e3 100644 --- a/src/backend/access/transam/transam.c +++ b/src/backend/access/transam/transam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.57 2004/07/01 00:49:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.58 2004/08/22 02:41:57 tgl Exp $ * * NOTES * This file contains the high level access-method interface to the @@ -22,6 +22,7 @@ #include "access/clog.h" #include "access/subtrans.h" #include "access/transam.h" +#include "utils/tqual.h" /* ---------------- @@ -199,11 +200,15 @@ TransactionIdDidCommit(TransactionId transactionId) /* * If it's marked subcommitted, we have to check the parent recursively. + * However, if it's older than RecentXmin, we can't look at pg_subtrans; + * instead assume that the parent crashed without cleaning up its children. */ if (xidstatus == TRANSACTION_STATUS_SUB_COMMITTED) { TransactionId parentXid; - + + if (TransactionIdPrecedes(transactionId, RecentXmin)) + return false; parentXid = SubTransGetParent(transactionId); Assert(TransactionIdIsValid(parentXid)); return TransactionIdDidCommit(parentXid); @@ -243,24 +248,17 @@ TransactionIdDidAbort(TransactionId transactionId) /* * If it's marked subcommitted, we have to check the parent recursively. - * - * If we detect that the parent has aborted, update pg_clog to show the - * subtransaction as aborted. This is only needed when the parent - * crashed before either committing or aborting. We want to clean up - * pg_clog so future visitors don't need to make this check again. + * However, if it's older than RecentXmin, we can't look at pg_subtrans; + * instead assume that the parent crashed without cleaning up its children. */ if (xidstatus == TRANSACTION_STATUS_SUB_COMMITTED) { TransactionId parentXid; - bool parentAborted; - - parentXid = SubTransGetParent(transactionId); - parentAborted = TransactionIdDidAbort(parentXid); - if (parentAborted) - TransactionIdAbort(transactionId); - - return parentAborted; + if (TransactionIdPrecedes(transactionId, RecentXmin)) + return true; + parentXid = SubTransGetParent(transactionId); + return TransactionIdDidAbort(parentXid); } /* |