diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-06 23:33:48 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-06 23:33:48 +0000 |
commit | 083258e535c58c97e52ade7b0b68b5ed1879a678 (patch) | |
tree | 23730c5d5c8a2c10d1496cb7e06010628aad5a0e /src/backend/storage/ipc/sinval.c | |
parent | d55588ea7a8a0203d27779263b1098688ee85bb2 (diff) | |
download | postgresql-083258e535c58c97e52ade7b0b68b5ed1879a678.tar.gz postgresql-083258e535c58c97e52ade7b0b68b5ed1879a678.zip |
Fix a number of places where brittle data structures or overly strong
Asserts would lead to a server core dump if an error occurred while
trying to abort a failed subtransaction (thereby leading to re-execution
of whatever parts of AbortSubTransaction had already run). This of course
does not prevent such an error from creating an infinite loop, but at
least we don't make the situation worse. Responds to an open item on
the subtransactions to-do list.
Diffstat (limited to 'src/backend/storage/ipc/sinval.c')
-rw-r--r-- | src/backend/storage/ipc/sinval.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c index 830d45169a6..5c4db3da807 100644 --- a/src/backend/storage/ipc/sinval.c +++ b/src/backend/storage/ipc/sinval.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/sinval.c,v 1.72 2004/08/29 05:06:48 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/sinval.c,v 1.73 2004/09/06 23:33:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1059,8 +1059,14 @@ XidCacheRemoveRunningXids(TransactionId xid, int nxids, TransactionId *xids) break; } } - /* We should have found it, unless the cache has overflowed */ - Assert(j >= 0 || MyProc->subxids.overflowed); + /* + * Ordinarily we should have found it, unless the cache has overflowed. + * However it's also possible for this routine to be invoked multiple + * times for the same subtransaction, in case of an error during + * AbortSubTransaction. So instead of Assert, emit a debug warning. + */ + if (j < 0 && !MyProc->subxids.overflowed) + elog(WARNING, "did not find subXID %u in MyProc", anxid); } for (j = MyProc->subxids.nxids - 1; j >= 0; j--) @@ -1071,8 +1077,9 @@ XidCacheRemoveRunningXids(TransactionId xid, int nxids, TransactionId *xids) break; } } - /* We should have found it, unless the cache has overflowed */ - Assert(j >= 0 || MyProc->subxids.overflowed); + /* Ordinarily we should have found it, unless the cache has overflowed */ + if (j < 0 && !MyProc->subxids.overflowed) + elog(WARNING, "did not find subXID %u in MyProc", xid); LWLockRelease(SInvalLock); } |