diff options
author | Thomas Munro <tmunro@postgresql.org> | 2019-04-12 14:53:38 +1200 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2019-04-12 16:47:50 +1200 |
commit | f7feb020c3d8d5aff24204af28359b99ee65bf8f (patch) | |
tree | 743cc3f8bccc8d48f309e593f1487c3ebcbc9e23 | |
parent | d87ab88686fb60ad5a34373de05bb20e632cf003 (diff) | |
download | postgresql-f7feb020c3d8d5aff24204af28359b99ee65bf8f.tar.gz postgresql-f7feb020c3d8d5aff24204af28359b99ee65bf8f.zip |
Fix GetNewTransactionId()'s interaction with xidVacLimit.
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
-rw-r--r-- | src/backend/access/transam/varsup.c | 3 | ||||
-rw-r--r-- | src/backend/access/transam/xact.c | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 8c3d84fbf23..788b961ef0e 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -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); } /* diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 816fd626ece..8522a2f51c5 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -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)); } /* |