mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
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.
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.259 2010/01/17 22:56:21 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.260 2010/01/24 21:49:17 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -3690,10 +3690,9 @@ AfterTriggerEndSubXact(bool isCommit)
|
||||
/*
|
||||
* Pop the prior state if needed.
|
||||
*/
|
||||
Assert(my_level < afterTriggers->maxtransdepth);
|
||||
|
||||
if (isCommit)
|
||||
{
|
||||
Assert(my_level < afterTriggers->maxtransdepth);
|
||||
/* If we saved a prior state, we don't need it anymore */
|
||||
state = afterTriggers->state_stack[my_level];
|
||||
if (state != NULL)
|
||||
@ -3706,8 +3705,16 @@ AfterTriggerEndSubXact(bool isCommit)
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Aborting. Release any event lists from queries being aborted, and
|
||||
* restore query_depth to its pre-subxact value.
|
||||
* Aborting. It is possible subxact start failed before calling
|
||||
* AfterTriggerBeginSubXact, in which case we mustn't risk touching
|
||||
* stack levels that aren't there.
|
||||
*/
|
||||
if (my_level >= afterTriggers->maxtransdepth)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Release any event lists from queries being aborted, and restore
|
||||
* query_depth to its pre-subxact value.
|
||||
*/
|
||||
while (afterTriggers->query_depth > afterTriggers->depth_stack[my_level])
|
||||
{
|
||||
|
Reference in New Issue
Block a user