mirror of
https://github.com/postgres/postgres.git
synced 2025-09-08 00:47:37 +03:00
Transaction IDs wrap around, per my proposal of 13-Aug-01. More
documentation to come, but the code is all here. initdb forced.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.39 2001/08/25 18:52:42 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.40 2001/08/26 16:56:00 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "storage/sinval.h"
|
||||
#include "storage/sinvaladt.h"
|
||||
#include "utils/tqual.h"
|
||||
#include "miscadmin.h"
|
||||
|
||||
|
||||
SPINLOCK SInvalLock = (SPINLOCK) NULL;
|
||||
|
||||
@@ -210,17 +212,23 @@ TransactionIdIsInProgress(TransactionId xid)
|
||||
}
|
||||
|
||||
/*
|
||||
* GetXmaxRecent -- returns oldest transaction that was running
|
||||
* when all current transaction were started.
|
||||
* It's used by vacuum to decide what deleted
|
||||
* tuples must be preserved in a table.
|
||||
* GetOldestXmin -- returns oldest transaction that was running
|
||||
* when any current transaction was started.
|
||||
*
|
||||
* Note: we include all currently running xids in the set of considered xids.
|
||||
* If allDbs is TRUE then all backends are considered; if allDbs is FALSE
|
||||
* then only backends running in my own database are considered.
|
||||
*
|
||||
* This is used by VACUUM to decide which deleted tuples must be preserved
|
||||
* in a table. allDbs = TRUE is needed for shared relations, but allDbs =
|
||||
* FALSE is sufficient for non-shared relations, since only backends in my
|
||||
* own database could ever see the tuples in them.
|
||||
*
|
||||
* Note: we include the currently running xids in the set of considered xids.
|
||||
* This ensures that if a just-started xact has not yet set its snapshot,
|
||||
* when it does set the snapshot it cannot set xmin less than what we compute.
|
||||
*/
|
||||
void
|
||||
GetXmaxRecent(TransactionId *XmaxRecent)
|
||||
TransactionId
|
||||
GetOldestXmin(bool allDbs)
|
||||
{
|
||||
SISeg *segP = shmInvalBuffer;
|
||||
ProcState *stateP = segP->procState;
|
||||
@@ -238,24 +246,28 @@ GetXmaxRecent(TransactionId *XmaxRecent)
|
||||
if (pOffset != INVALID_OFFSET)
|
||||
{
|
||||
PROC *proc = (PROC *) MAKE_PTR(pOffset);
|
||||
/* Fetch xid just once - see GetNewTransactionId */
|
||||
TransactionId xid = proc->xid;
|
||||
|
||||
if (TransactionIdIsNormal(xid))
|
||||
if (allDbs || proc->databaseId == MyDatabaseId)
|
||||
{
|
||||
if (TransactionIdPrecedes(xid, result))
|
||||
result = xid;
|
||||
xid = proc->xmin;
|
||||
/* Fetch xid just once - see GetNewTransactionId */
|
||||
TransactionId xid = proc->xid;
|
||||
|
||||
if (TransactionIdIsNormal(xid))
|
||||
{
|
||||
if (TransactionIdPrecedes(xid, result))
|
||||
result = xid;
|
||||
xid = proc->xmin;
|
||||
if (TransactionIdIsNormal(xid))
|
||||
if (TransactionIdPrecedes(xid, result))
|
||||
result = xid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SpinRelease(SInvalLock);
|
||||
|
||||
*XmaxRecent = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*----------
|
||||
|
Reference in New Issue
Block a user