]> granicus.if.org Git - postgresql/commitdiff
Fix GetNewTransactionId()'s interaction with xidVacLimit.
authorThomas Munro <tmunro@postgresql.org>
Fri, 12 Apr 2019 02:53:38 +0000 (14:53 +1200)
committerThomas Munro <tmunro@postgresql.org>
Fri, 12 Apr 2019 04:47:50 +0000 (16:47 +1200)
Commit ad308058 switched to returning a FullTransactionId, but
failed to load the potentially updated value in the case where
xidVacLimit is reached and we release and reacquire the lock.
Repair, closing bug #15727.

While reviewing that commit, also fix the size computation used
by EstimateTransactionStateSize() and switch to the mul_size()
macro traditionally used in such expressions.

Author: Thomas Munro
Reported-by: Roman Zharkov
Discussion: https://postgr.es/m/15727-0be246e7d852d229%40postgresql.org

src/backend/access/transam/varsup.c
src/backend/access/transam/xact.c

index 8c3d84fbf238c94c012efee6d97d18210e726d67..788b961ef0ec683c46cf1536f1d6a89a81d9f9a2 100644 (file)
@@ -159,7 +159,8 @@ GetNewTransactionId(bool isSubXact)
 
                /* Re-acquire lock and start over */
                LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
-               xid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);
+               full_xid = ShmemVariableCache->nextFullXid;
+               xid = XidFromFullTransactionId(full_xid);
        }
 
        /*
index 816fd626ece41d1c0a407d913da7a76502773897..8522a2f51c587f2e6e5ae64d2723671172fa8fde 100644 (file)
@@ -5151,7 +5151,7 @@ EstimateTransactionStateSpace(void)
                nxids = add_size(nxids, s->nChildXids);
        }
 
-       return add_size(size, sizeof(SerializedTransactionState) * nxids);
+       return add_size(size, mul_size(sizeof(TransactionId), nxids));
 }
 
 /*