Skip to content

Commit b786304

Browse files
author
Amit Kapila
committed
Fix race condition in TransactionGroupUpdateXidStatus().
When we cannot immediately acquire XactSLRULock in exclusive mode at commit time, we add ourselves to a list of processes that need their XIDs status update. We do this if the clog page where we need to update the current transaction status is the same as the group leader's clog page, otherwise, we allow the caller to clear it by itself. Now, when we can't add ourselves to any group, we were not clearing the current proc if it has already become a member of some group which was leading to an assertion failure when the same proc was assigned to another backend after the current backend exits. Reported-by: Alexander Lakhin Bug: 17072 Author: Amit Kapila Tested-By: Alexander Lakhin Backpatch-through: 11, where it was introduced Discussion: https://postgr.es/m/17072-2f8764857ef2c92a@postgresql.org
1 parent 34a8b64 commit b786304

File tree

1 file changed

+5
-0
lines changed
  • src/backend/access/transam

1 file changed

+5
-0
lines changed

src/backend/access/transam/clog.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,12 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
451451
if (nextidx != INVALID_PGPROCNO &&
452452
ProcGlobal->allProcs[nextidx].clogGroupMemberPage != proc->clogGroupMemberPage)
453453
{
454+
/*
455+
* Ensure that this proc is not a member of any clog group that
456+
* needs an XID status update.
457+
*/
454458
proc->clogGroupMember = false;
459+
pg_atomic_write_u32(&proc->clogGroupNext, INVALID_PGPROCNO);
455460
return false;
456461
}
457462

0 commit comments

Comments
 (0)