Skip to content

Commit 46c333a

Browse files
committed
Fix overly strict assertion in SummarizeOldestCommittedSxact(). There's a
race condition where SummarizeOldestCommittedSxact() is called even though another backend already cleared out all finished sxact entries. That's OK, RegisterSerializableTransactionInt() can just retry getting a news xact slot from the available-list when that happens. Reported by YAMAMOTO Takashi, bug #5918.
1 parent 93d8882 commit 46c333a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/backend/storage/lmgr/predicate.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,15 +1314,21 @@ SummarizeOldestCommittedSxact(void)
13141314

13151315
LWLockAcquire(SerializableFinishedListLock, LW_EXCLUSIVE);
13161316

1317-
#ifdef TEST_OLDSERXID
1317+
/*
1318+
* This function is only called if there are no sxact slots available.
1319+
* Some of them must belong to old, already-finished transactions, so
1320+
* there should be something in FinishedSerializableTransactions list
1321+
* that we can summarize. However, there's a race condition: while we
1322+
* were not holding any locks, a transaction might have ended and cleaned
1323+
* up all the finished sxact entries already, freeing up their sxact
1324+
* slots. In that case, we have nothing to do here. The caller will find
1325+
* one of the slots released by the other backend when it retries.
1326+
*/
13181327
if (SHMQueueEmpty(FinishedSerializableTransactions))
13191328
{
13201329
LWLockRelease(SerializableFinishedListLock);
13211330
return;
13221331
}
1323-
#else
1324-
Assert(!SHMQueueEmpty(FinishedSerializableTransactions));
1325-
#endif
13261332

13271333
/*
13281334
* Grab the first sxact off the finished list -- this will be the earliest

0 commit comments

Comments
 (0)