From f5247fb8bd231c045b72288d01ed3c819b978495 Mon Sep 17 00:00:00 2001
From: Dilip Kumar <dilip.kumar@enterprisedb.com>
Date: Tue, 10 Dec 2019 13:39:35 +0530
Subject: [PATCH v1] Change wrong assert while group updating xid status
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The function assumes that an overflowed transaction can never get registered
for the group update.  But, actually, that is not true because while registering
the transaction for group update we only check how many committed children this
transaction has because all aborted sub-transaction would have already updated
their status.  So if the transaction once overflowed but later all its children
are aborted then it will be registered for the group update.

Patch by Dilip Kumar, Bug reported by Vignesh C
---
 src/backend/access/transam/clog.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 7f7eb21..0e24b3c 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -520,10 +520,10 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
 		PGXACT	   *pgxact = &ProcGlobal->allPgXact[nextidx];
 
 		/*
-		 * Overflowed transactions should not use group XID status update
-		 * mechanism.
+		 * Transactions with more than THRESHOLD_SUBTRANS_CLOG_OPT sub-XIDs
+		 * should not use group XID status update mechanism.
 		 */
-		Assert(!pgxact->overflowed);
+		Assert(pgxact->nxids <= THRESHOLD_SUBTRANS_CLOG_OPT);
 
 		TransactionIdSetPageStatusInternal(proc->clogGroupMemberXid,
 										   pgxact->nxids,
-- 
1.8.3.1

