diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-01-24 21:50:09 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-01-24 21:50:09 +0000 |
commit | ce95d0f14d2a6374014e852a6a1f20d30a0f69f6 (patch) | |
tree | a7f1ef30ce70a74de1b89b3c27b00e7713a19b8e /src/backend/utils/misc/guc.c | |
parent | 34d7ef60e7ff5d34058822db33953c279818ceb8 (diff) | |
download | postgresql-ce95d0f14d2a6374014e852a6a1f20d30a0f69f6.tar.gz postgresql-ce95d0f14d2a6374014e852a6a1f20d30a0f69f6.zip |
Fix assorted core dumps and Assert failures that could occur during
AbortTransaction or AbortSubTransaction, when trying to clean up after an
error that prevented (sub)transaction start from completing:
* access to TopTransactionResourceOwner that might not exist
* assert failure in AtEOXact_GUC, if AtStart_GUC not called yet
* assert failure or core dump in AfterTriggerEndSubXact, if
AfterTriggerBeginSubXact not called yet
Per testing by injecting elog(ERROR) at successive steps in StartTransaction
and StartSubTransaction. It's not clear whether all of these cases could
really occur in the field, but at least one of them is easily exposed by
simple stress testing, as per my accidental discovery yesterday.
Diffstat (limited to 'src/backend/utils/misc/guc.c')
-rw-r--r-- | src/backend/utils/misc/guc.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 06b7f54e887..6e4f0bd2a41 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut <peter_e@gmx.net>. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.252.4.7 2009/12/09 21:58:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.252.4.8 2010/01/24 21:50:09 tgl Exp $ * *-------------------------------------------------------------------- */ @@ -2848,7 +2848,14 @@ AtEOXact_GUC(bool isCommit, int nestLevel) { int i; - Assert(nestLevel > 0 && nestLevel <= GUCNestLevel); + /* + * Note: it's possible to get here with GUCNestLevel == nestLevel-1 during + * abort, if there is a failure during transaction start before + * AtStart_GUC is called. + */ + Assert(nestLevel > 0 && + (nestLevel <= GUCNestLevel || + (nestLevel == GUCNestLevel + 1 && !isCommit))); /* Quick exit if nothing's changed in this transaction */ if (!guc_dirty) |