aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xact.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-08-28 20:31:44 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-08-28 20:31:44 +0000
commit1c72d0dec1d9e087ddf4010fac098153677bf77d (patch)
treea8b1b309ed00be2afe1152e4001552ff6496dddf /src/backend/access/transam/xact.c
parentf900af7961fb7009242dbcaf3b484d4b1ed8752d (diff)
downloadpostgresql-1c72d0dec1d9e087ddf4010fac098153677bf77d.tar.gz
postgresql-1c72d0dec1d9e087ddf4010fac098153677bf77d.zip
Fix relcache to account properly for subtransaction status of 'new'
relcache entries. Also, change TransactionIdIsCurrentTransactionId() so that if consulted during transaction abort, it will not say that the aborted xact is still current. (It would be better to ensure that it's never called at all during abort, but I'm not sure we can easily guarantee that.) In combination, these fix a crash we have seen occasionally during parallel regression tests of 8.0.
Diffstat (limited to 'src/backend/access/transam/xact.c')
-rw-r--r--src/backend/access/transam/xact.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 25d5048ed82..56ae070acb7 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.179 2004/08/25 18:43:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.180 2004/08/28 20:31:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,6 +40,7 @@
#include "utils/inval.h"
#include "utils/memutils.h"
#include "utils/portal.h"
+#include "utils/relcache.h"
#include "utils/resowner.h"
#include "pgstat.h"
@@ -352,7 +353,7 @@ GetCurrentTransactionNestLevel(void)
bool
TransactionIdIsCurrentTransactionId(TransactionId xid)
{
- TransactionState s = CurrentTransactionState;
+ TransactionState s;
if (AMI_OVERRIDE)
{
@@ -363,12 +364,16 @@ TransactionIdIsCurrentTransactionId(TransactionId xid)
/*
* We will return true for the Xid of the current subtransaction,
* any of its subcommitted children, any of its parents, or any of
- * their previously subcommitted children.
+ * their previously subcommitted children. However, a transaction
+ * being aborted is no longer "current", even though it may still
+ * have an entry on the state stack.
*/
- while (s != NULL)
+ for (s = CurrentTransactionState; s != NULL; s = s->parent)
{
ListCell *cell;
+ if (s->state == TRANS_ABORT)
+ continue;
if (TransactionIdEquals(xid, s->transactionIdData))
return true;
foreach(cell, s->childXids)
@@ -376,8 +381,6 @@ TransactionIdIsCurrentTransactionId(TransactionId xid)
if (TransactionIdEquals(xid, lfirst_xid(cell)))
return true;
}
-
- s = s->parent;
}
return false;
@@ -2997,6 +3000,8 @@ CommitSubTransaction(void)
ResourceOwnerRelease(s->curTransactionOwner,
RESOURCE_RELEASE_BEFORE_LOCKS,
true, false);
+ AtEOSubXact_RelationCache(true, s->transactionIdData,
+ s->parent->transactionIdData);
AtEOSubXact_Inval(true);
ResourceOwnerRelease(s->curTransactionOwner,
RESOURCE_RELEASE_LOCKS,
@@ -3090,6 +3095,8 @@ AbortSubTransaction(void)
ResourceOwnerRelease(s->curTransactionOwner,
RESOURCE_RELEASE_BEFORE_LOCKS,
false, false);
+ AtEOSubXact_RelationCache(false, s->transactionIdData,
+ s->parent->transactionIdData);
AtEOSubXact_Inval(false);
ResourceOwnerRelease(s->curTransactionOwner,
RESOURCE_RELEASE_LOCKS,