summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Kapila2021-06-28 03:59:38 +0000
committerAmit Kapila2021-06-28 03:59:38 +0000
commitb786304c2904a4e444fe740bbc2e0b69efacc19d (patch)
tree483d0e5df09b7212d9ea61c85995795308928e2b
parent34a8b64b4e5f0cd818e5cc7f98846de57938ea57 (diff)
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/[email protected]
-rw-r--r--src/backend/access/transam/clog.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..3ea16a270a 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -451,7 +451,12 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
if (nextidx != INVALID_PGPROCNO &&
ProcGlobal->allProcs[nextidx].clogGroupMemberPage != proc->clogGroupMemberPage)
{
+ /*
+ * Ensure that this proc is not a member of any clog group that
+ * needs an XID status update.
+ */
proc->clogGroupMember = false;
+ pg_atomic_write_u32(&proc->clogGroupNext, INVALID_PGPROCNO);
return false;
}