Skip to content

Commit e1b13cc

Browse files
simonat2ndQuadrantkelvich
authored andcommitted
Exit correctly from PrepareRedoRemove() when not found
Complex crash bug all started with this failure. Diagnosed and fixed by Nikhil Sontakke, reviewed by me. Reported-by: Jeff Janes Author: Nikhil Sontakke Discussion: https://postgr.es/m/CAMkU=1xBP8cqdS5eK8APHL=X6RHMMM2vG5g+QamduuTsyCwv9g@mail.gmail.com
1 parent bfc79ee commit e1b13cc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/backend/access/transam/twophase.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,7 @@ PrepareRedoRemove(TransactionId xid, bool giveWarning)
26332633
{
26342634
GlobalTransaction gxact = NULL;
26352635
int i;
2636+
bool found = false;
26362637

26372638
Assert(LWLockHeldByMeInMode(TwoPhaseStateLock, LW_EXCLUSIVE));
26382639
Assert(RecoveryInProgress());
@@ -2644,14 +2645,15 @@ PrepareRedoRemove(TransactionId xid, bool giveWarning)
26442645
if (gxact->xid == xid)
26452646
{
26462647
Assert(gxact->inredo);
2648+
found = true;
26472649
break;
26482650
}
26492651
}
26502652

26512653
/*
26522654
* Just leave if there is nothing, this is expected during WAL replay.
26532655
*/
2654-
if (gxact == NULL)
2656+
if (!found)
26552657
return;
26562658

26572659
/*

0 commit comments

Comments
 (0)