Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ad30805

Browse files
committed
Use FullTransactionId for the transaction stack.
Provide GetTopFullTransactionId() and GetCurrentFullTransactionId(). The intended users of these interfaces are access methods that use xids for visibility checks but don't want to have to go back and "freeze" existing references some time later before the 32 bit xid counter wraps around. Use a new struct to serialize the transaction state for parallel query, because FullTransactionId doesn't fit into the previous serialization scheme very well. Author: Thomas Munro Reviewed-by: Heikki Linnakangas Discussion: https://postgr.es/m/CAA4eK1%2BMv%2Bmb0HFfWM9Srtc6MVe160WFurXV68iAFMcagRZ0dQ%40mail.gmail.com
1 parent 2fc7af5 commit ad30805

File tree

5 files changed

+170
-81
lines changed

5 files changed

+170
-81
lines changed

src/backend/access/transam/varsup.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ VariableCache ShmemVariableCache = NULL;
3535

3636

3737
/*
38-
* Allocate the next XID for a new transaction or subtransaction.
38+
* Allocate the next FullTransactionId for a new transaction or
39+
* subtransaction.
3940
*
4041
* The new XID is also stored into MyPgXact before returning.
4142
*
@@ -44,9 +45,10 @@ VariableCache ShmemVariableCache = NULL;
4445
* does something. So it is safe to do a database lookup if we want to
4546
* issue a warning about XID wrap.
4647
*/
47-
TransactionId
48+
FullTransactionId
4849
GetNewTransactionId(bool isSubXact)
4950
{
51+
FullTransactionId full_xid;
5052
TransactionId xid;
5153

5254
/*
@@ -64,7 +66,7 @@ GetNewTransactionId(bool isSubXact)
6466
{
6567
Assert(!isSubXact);
6668
MyPgXact->xid = BootstrapTransactionId;
67-
return BootstrapTransactionId;
69+
return FullTransactionIdFromEpochAndXid(0, BootstrapTransactionId);
6870
}
6971

7072
/* safety check, we should never get this far in a HS standby */
@@ -73,7 +75,8 @@ GetNewTransactionId(bool isSubXact)
7375

7476
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
7577

76-
xid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);
78+
full_xid = ShmemVariableCache->nextFullXid;
79+
xid = XidFromFullTransactionId(full_xid);
7780

7881
/*----------
7982
* Check to see if it's safe to assign another XID. This protects against
@@ -232,7 +235,7 @@ GetNewTransactionId(bool isSubXact)
232235

233236
LWLockRelease(XidGenLock);
234237

235-
return xid;
238+
return full_xid;
236239
}
237240

238241
/*

0 commit comments

Comments
 (0)