Commit 241448b2 authored by Joe Conway's avatar Joe Conway

Rename (new|old)estCommitTs to (new|old)estCommitTsXid

The variables newestCommitTs and oldestCommitTs sound as if they are
timestamps, but in fact they are the transaction Ids that correspond
to the newest and oldest timestamps rather than the actual timestamps.
Rename these variables to reflect that they are actually xids: to wit
newestCommitTsXid and oldestCommitTsXid respectively. Also modify
related code in a similar fashion, particularly the user facing output
emitted by pg_controldata and pg_resetxlog.

Complaint and patch by me, review by Tom Lane and Alvaro Herrera.
Backpatch to 9.5 where these variables were first introduced.
parent 81ee726d
...@@ -59,8 +59,8 @@ xlog_desc(StringInfo buf, XLogReaderState *record) ...@@ -59,8 +59,8 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->oldestXidDB, checkpoint->oldestXidDB,
checkpoint->oldestMulti, checkpoint->oldestMulti,
checkpoint->oldestMultiDB, checkpoint->oldestMultiDB,
checkpoint->oldestCommitTs, checkpoint->oldestCommitTsXid,
checkpoint->newestCommitTs, checkpoint->newestCommitTsXid,
checkpoint->oldestActiveXid, checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online"); (info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
} }
......
...@@ -217,8 +217,8 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids, ...@@ -217,8 +217,8 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
commitTsShared->dataLastCommit.nodeid = nodeid; commitTsShared->dataLastCommit.nodeid = nodeid;
/* and move forwards our endpoint, if needed */ /* and move forwards our endpoint, if needed */
if (TransactionIdPrecedes(ShmemVariableCache->newestCommitTs, newestXact)) if (TransactionIdPrecedes(ShmemVariableCache->newestCommitTsXid, newestXact))
ShmemVariableCache->newestCommitTs = newestXact; ShmemVariableCache->newestCommitTsXid = newestXact;
LWLockRelease(CommitTsLock); LWLockRelease(CommitTsLock);
} }
...@@ -285,8 +285,8 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts, ...@@ -285,8 +285,8 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
int entryno = TransactionIdToCTsEntry(xid); int entryno = TransactionIdToCTsEntry(xid);
int slotno; int slotno;
CommitTimestampEntry entry; CommitTimestampEntry entry;
TransactionId oldestCommitTs; TransactionId oldestCommitTsXid;
TransactionId newestCommitTs; TransactionId newestCommitTsXid;
/* error if the given Xid doesn't normally commit */ /* error if the given Xid doesn't normally commit */
if (!TransactionIdIsNormal(xid)) if (!TransactionIdIsNormal(xid))
...@@ -314,18 +314,18 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts, ...@@ -314,18 +314,18 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
return *ts != 0; return *ts != 0;
} }
oldestCommitTs = ShmemVariableCache->oldestCommitTs; oldestCommitTsXid = ShmemVariableCache->oldestCommitTsXid;
newestCommitTs = ShmemVariableCache->newestCommitTs; newestCommitTsXid = ShmemVariableCache->newestCommitTsXid;
/* neither is invalid, or both are */ /* neither is invalid, or both are */
Assert(TransactionIdIsValid(oldestCommitTs) == TransactionIdIsValid(newestCommitTs)); Assert(TransactionIdIsValid(oldestCommitTsXid) == TransactionIdIsValid(newestCommitTsXid));
LWLockRelease(CommitTsLock); LWLockRelease(CommitTsLock);
/* /*
* Return empty if the requested value is outside our valid range. * Return empty if the requested value is outside our valid range.
*/ */
if (!TransactionIdIsValid(oldestCommitTs) || if (!TransactionIdIsValid(oldestCommitTsXid) ||
TransactionIdPrecedes(xid, oldestCommitTs) || TransactionIdPrecedes(xid, oldestCommitTsXid) ||
TransactionIdPrecedes(newestCommitTs, xid)) TransactionIdPrecedes(newestCommitTsXid, xid))
{ {
*ts = 0; *ts = 0;
if (nodeid) if (nodeid)
...@@ -655,14 +655,14 @@ ActivateCommitTs(void) ...@@ -655,14 +655,14 @@ ActivateCommitTs(void)
* enabled again? It doesn't look like it does, because there should be a * enabled again? It doesn't look like it does, because there should be a
* checkpoint that sets the value to InvalidTransactionId at end of * checkpoint that sets the value to InvalidTransactionId at end of
* recovery; and so any chance of injecting new transactions without * recovery; and so any chance of injecting new transactions without
* CommitTs values would occur after the oldestCommitTs has been set to * CommitTs values would occur after the oldestCommitTsXid has been set to
* Invalid temporarily. * Invalid temporarily.
*/ */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE); LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
if (ShmemVariableCache->oldestCommitTs == InvalidTransactionId) if (ShmemVariableCache->oldestCommitTsXid == InvalidTransactionId)
{ {
ShmemVariableCache->oldestCommitTs = ShmemVariableCache->oldestCommitTsXid =
ShmemVariableCache->newestCommitTs = ReadNewTransactionId(); ShmemVariableCache->newestCommitTsXid = ReadNewTransactionId();
} }
LWLockRelease(CommitTsLock); LWLockRelease(CommitTsLock);
...@@ -711,8 +711,8 @@ DeactivateCommitTs(void) ...@@ -711,8 +711,8 @@ DeactivateCommitTs(void)
TIMESTAMP_NOBEGIN(commitTsShared->dataLastCommit.time); TIMESTAMP_NOBEGIN(commitTsShared->dataLastCommit.time);
commitTsShared->dataLastCommit.nodeid = InvalidRepOriginId; commitTsShared->dataLastCommit.nodeid = InvalidRepOriginId;
ShmemVariableCache->oldestCommitTs = InvalidTransactionId; ShmemVariableCache->oldestCommitTsXid = InvalidTransactionId;
ShmemVariableCache->newestCommitTs = InvalidTransactionId; ShmemVariableCache->newestCommitTsXid = InvalidTransactionId;
LWLockRelease(CommitTsLock); LWLockRelease(CommitTsLock);
...@@ -832,16 +832,16 @@ SetCommitTsLimit(TransactionId oldestXact, TransactionId newestXact) ...@@ -832,16 +832,16 @@ SetCommitTsLimit(TransactionId oldestXact, TransactionId newestXact)
* "future" or signal a disabled committs. * "future" or signal a disabled committs.
*/ */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE); LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
if (ShmemVariableCache->oldestCommitTs != InvalidTransactionId) if (ShmemVariableCache->oldestCommitTsXid != InvalidTransactionId)
{ {
if (TransactionIdPrecedes(ShmemVariableCache->oldestCommitTs, oldestXact)) if (TransactionIdPrecedes(ShmemVariableCache->oldestCommitTsXid, oldestXact))
ShmemVariableCache->oldestCommitTs = oldestXact; ShmemVariableCache->oldestCommitTsXid = oldestXact;
if (TransactionIdPrecedes(newestXact, ShmemVariableCache->newestCommitTs)) if (TransactionIdPrecedes(newestXact, ShmemVariableCache->newestCommitTsXid))
ShmemVariableCache->newestCommitTs = newestXact; ShmemVariableCache->newestCommitTsXid = newestXact;
} }
else else
{ {
Assert(ShmemVariableCache->newestCommitTs == InvalidTransactionId); Assert(ShmemVariableCache->newestCommitTsXid == InvalidTransactionId);
} }
LWLockRelease(CommitTsLock); LWLockRelease(CommitTsLock);
} }
...@@ -850,12 +850,12 @@ SetCommitTsLimit(TransactionId oldestXact, TransactionId newestXact) ...@@ -850,12 +850,12 @@ SetCommitTsLimit(TransactionId oldestXact, TransactionId newestXact)
* Move forwards the oldest commitTS value that can be consulted * Move forwards the oldest commitTS value that can be consulted
*/ */
void void
AdvanceOldestCommitTs(TransactionId oldestXact) AdvanceOldestCommitTsXid(TransactionId oldestXact)
{ {
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE); LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
if (ShmemVariableCache->oldestCommitTs != InvalidTransactionId && if (ShmemVariableCache->oldestCommitTsXid != InvalidTransactionId &&
TransactionIdPrecedes(ShmemVariableCache->oldestCommitTs, oldestXact)) TransactionIdPrecedes(ShmemVariableCache->oldestCommitTsXid, oldestXact))
ShmemVariableCache->oldestCommitTs = oldestXact; ShmemVariableCache->oldestCommitTsXid = oldestXact;
LWLockRelease(CommitTsLock); LWLockRelease(CommitTsLock);
} }
......
...@@ -4782,8 +4782,8 @@ BootStrapXLOG(void) ...@@ -4782,8 +4782,8 @@ BootStrapXLOG(void)
checkPoint.oldestXidDB = TemplateDbOid; checkPoint.oldestXidDB = TemplateDbOid;
checkPoint.oldestMulti = FirstMultiXactId; checkPoint.oldestMulti = FirstMultiXactId;
checkPoint.oldestMultiDB = TemplateDbOid; checkPoint.oldestMultiDB = TemplateDbOid;
checkPoint.oldestCommitTs = InvalidTransactionId; checkPoint.oldestCommitTsXid = InvalidTransactionId;
checkPoint.newestCommitTs = InvalidTransactionId; checkPoint.newestCommitTsXid = InvalidTransactionId;
checkPoint.time = (pg_time_t) time(NULL); checkPoint.time = (pg_time_t) time(NULL);
checkPoint.oldestActiveXid = InvalidTransactionId; checkPoint.oldestActiveXid = InvalidTransactionId;
...@@ -6298,8 +6298,8 @@ StartupXLOG(void) ...@@ -6298,8 +6298,8 @@ StartupXLOG(void)
checkPoint.oldestMulti, checkPoint.oldestMultiDB))); checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
ereport(DEBUG1, ereport(DEBUG1,
(errmsg_internal("commit timestamp Xid oldest/newest: %u/%u", (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
checkPoint.oldestCommitTs, checkPoint.oldestCommitTsXid,
checkPoint.newestCommitTs))); checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(checkPoint.nextXid)) if (!TransactionIdIsNormal(checkPoint.nextXid))
ereport(PANIC, ereport(PANIC,
(errmsg("invalid next transaction ID"))); (errmsg("invalid next transaction ID")));
...@@ -6311,8 +6311,8 @@ StartupXLOG(void) ...@@ -6311,8 +6311,8 @@ StartupXLOG(void)
MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset); MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset);
SetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB); SetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB);
SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB); SetMultiXactIdLimit(checkPoint.oldestMulti, checkPoint.oldestMultiDB);
SetCommitTsLimit(checkPoint.oldestCommitTs, SetCommitTsLimit(checkPoint.oldestCommitTsXid,
checkPoint.newestCommitTs); checkPoint.newestCommitTsXid);
XLogCtl->ckptXidEpoch = checkPoint.nextXidEpoch; XLogCtl->ckptXidEpoch = checkPoint.nextXidEpoch;
XLogCtl->ckptXid = checkPoint.nextXid; XLogCtl->ckptXid = checkPoint.nextXid;
...@@ -8330,8 +8330,8 @@ CreateCheckPoint(int flags) ...@@ -8330,8 +8330,8 @@ CreateCheckPoint(int flags)
LWLockRelease(XidGenLock); LWLockRelease(XidGenLock);
LWLockAcquire(CommitTsLock, LW_SHARED); LWLockAcquire(CommitTsLock, LW_SHARED);
checkPoint.oldestCommitTs = ShmemVariableCache->oldestCommitTs; checkPoint.oldestCommitTsXid = ShmemVariableCache->oldestCommitTsXid;
checkPoint.newestCommitTs = ShmemVariableCache->newestCommitTs; checkPoint.newestCommitTsXid = ShmemVariableCache->newestCommitTsXid;
LWLockRelease(CommitTsLock); LWLockRelease(CommitTsLock);
/* Increase XID epoch if we've wrapped around since last checkpoint */ /* Increase XID epoch if we've wrapped around since last checkpoint */
......
...@@ -1151,7 +1151,7 @@ vac_truncate_clog(TransactionId frozenXID, ...@@ -1151,7 +1151,7 @@ vac_truncate_clog(TransactionId frozenXID,
*/ */
SetTransactionIdLimit(frozenXID, oldestxid_datoid); SetTransactionIdLimit(frozenXID, oldestxid_datoid);
SetMultiXactIdLimit(minMulti, minmulti_datoid); SetMultiXactIdLimit(minMulti, minmulti_datoid);
AdvanceOldestCommitTs(frozenXID); AdvanceOldestCommitTsXid(frozenXID);
} }
......
...@@ -271,10 +271,10 @@ main(int argc, char *argv[]) ...@@ -271,10 +271,10 @@ main(int argc, char *argv[])
ControlFile.checkPointCopy.oldestMulti); ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"), printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB); ControlFile.checkPointCopy.oldestMultiDB);
printf(_("Latest checkpoint's oldestCommitTs: %u\n"), printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
ControlFile.checkPointCopy.oldestCommitTs); ControlFile.checkPointCopy.oldestCommitTsXid);
printf(_("Latest checkpoint's newestCommitTs: %u\n"), printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
ControlFile.checkPointCopy.newestCommitTs); ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"), printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str); ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"), printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
......
...@@ -64,8 +64,8 @@ static bool guessed = false; /* T if we had to guess at any values */ ...@@ -64,8 +64,8 @@ static bool guessed = false; /* T if we had to guess at any values */
static const char *progname; static const char *progname;
static uint32 set_xid_epoch = (uint32) -1; static uint32 set_xid_epoch = (uint32) -1;
static TransactionId set_xid = 0; static TransactionId set_xid = 0;
static TransactionId set_oldest_commit_ts = 0; static TransactionId set_oldest_commit_ts_xid = 0;
static TransactionId set_newest_commit_ts = 0; static TransactionId set_newest_commit_ts_xid = 0;
static Oid set_oid = 0; static Oid set_oid = 0;
static MultiXactId set_mxid = 0; static MultiXactId set_mxid = 0;
static MultiXactOffset set_mxoff = (MultiXactOffset) -1; static MultiXactOffset set_mxoff = (MultiXactOffset) -1;
...@@ -164,14 +164,14 @@ main(int argc, char *argv[]) ...@@ -164,14 +164,14 @@ main(int argc, char *argv[])
break; break;
case 'c': case 'c':
set_oldest_commit_ts = strtoul(optarg, &endptr, 0); set_oldest_commit_ts_xid = strtoul(optarg, &endptr, 0);
if (endptr == optarg || *endptr != ',') if (endptr == optarg || *endptr != ',')
{ {
fprintf(stderr, _("%s: invalid argument for option %s\n"), progname, "-c"); fprintf(stderr, _("%s: invalid argument for option %s\n"), progname, "-c");
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1); exit(1);
} }
set_newest_commit_ts = strtoul(endptr + 1, &endptr2, 0); set_newest_commit_ts_xid = strtoul(endptr + 1, &endptr2, 0);
if (endptr2 == endptr + 1 || *endptr2 != '\0') if (endptr2 == endptr + 1 || *endptr2 != '\0')
{ {
fprintf(stderr, _("%s: invalid argument for option %s\n"), progname, "-c"); fprintf(stderr, _("%s: invalid argument for option %s\n"), progname, "-c");
...@@ -179,15 +179,15 @@ main(int argc, char *argv[]) ...@@ -179,15 +179,15 @@ main(int argc, char *argv[])
exit(1); exit(1);
} }
if (set_oldest_commit_ts < 2 && if (set_oldest_commit_ts_xid < 2 &&
set_oldest_commit_ts != 0) set_oldest_commit_ts_xid != 0)
{ {
fprintf(stderr, _("%s: transaction ID (-c) must be either 0 or greater than or equal to 2\n"), progname); fprintf(stderr, _("%s: transaction ID (-c) must be either 0 or greater than or equal to 2\n"), progname);
exit(1); exit(1);
} }
if (set_newest_commit_ts < 2 && if (set_newest_commit_ts_xid < 2 &&
set_newest_commit_ts != 0) set_newest_commit_ts_xid != 0)
{ {
fprintf(stderr, _("%s: transaction ID (-c) must be either 0 or greater than or equal to 2\n"), progname); fprintf(stderr, _("%s: transaction ID (-c) must be either 0 or greater than or equal to 2\n"), progname);
exit(1); exit(1);
...@@ -383,10 +383,10 @@ main(int argc, char *argv[]) ...@@ -383,10 +383,10 @@ main(int argc, char *argv[])
ControlFile.checkPointCopy.oldestXidDB = InvalidOid; ControlFile.checkPointCopy.oldestXidDB = InvalidOid;
} }
if (set_oldest_commit_ts != 0) if (set_oldest_commit_ts_xid != 0)
ControlFile.checkPointCopy.oldestCommitTs = set_oldest_commit_ts; ControlFile.checkPointCopy.oldestCommitTsXid = set_oldest_commit_ts_xid;
if (set_newest_commit_ts != 0) if (set_newest_commit_ts_xid != 0)
ControlFile.checkPointCopy.newestCommitTs = set_newest_commit_ts; ControlFile.checkPointCopy.newestCommitTsXid = set_newest_commit_ts_xid;
if (set_oid != 0) if (set_oid != 0)
ControlFile.checkPointCopy.nextOid = set_oid; ControlFile.checkPointCopy.nextOid = set_oid;
...@@ -665,10 +665,10 @@ PrintControlValues(bool guessed) ...@@ -665,10 +665,10 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.oldestMulti); ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"), printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB); ControlFile.checkPointCopy.oldestMultiDB);
printf(_("Latest checkpoint's oldestCommitTs: %u\n"), printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
ControlFile.checkPointCopy.oldestCommitTs); ControlFile.checkPointCopy.oldestCommitTsXid);
printf(_("Latest checkpoint's newestCommitTs: %u\n"), printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
ControlFile.checkPointCopy.newestCommitTs); ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"), printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign); ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */ /* we don't print floatFormat since can't say much useful about it */
...@@ -751,15 +751,15 @@ PrintNewControlValues(void) ...@@ -751,15 +751,15 @@ PrintNewControlValues(void)
ControlFile.checkPointCopy.nextXidEpoch); ControlFile.checkPointCopy.nextXidEpoch);
} }
if (set_oldest_commit_ts != 0) if (set_oldest_commit_ts_xid != 0)
{ {
printf(_("oldestCommitTs: %u\n"), printf(_("oldestCommitTsXid: %u\n"),
ControlFile.checkPointCopy.oldestCommitTs); ControlFile.checkPointCopy.oldestCommitTsXid);
} }
if (set_newest_commit_ts != 0) if (set_newest_commit_ts_xid != 0)
{ {
printf(_("newestCommitTs: %u\n"), printf(_("newestCommitTsXid: %u\n"),
ControlFile.checkPointCopy.newestCommitTs); ControlFile.checkPointCopy.newestCommitTsXid);
} }
} }
......
...@@ -43,7 +43,7 @@ extern void ExtendCommitTs(TransactionId newestXact); ...@@ -43,7 +43,7 @@ extern void ExtendCommitTs(TransactionId newestXact);
extern void TruncateCommitTs(TransactionId oldestXact); extern void TruncateCommitTs(TransactionId oldestXact);
extern void SetCommitTsLimit(TransactionId oldestXact, extern void SetCommitTsLimit(TransactionId oldestXact,
TransactionId newestXact); TransactionId newestXact);
extern void AdvanceOldestCommitTs(TransactionId oldestXact); extern void AdvanceOldestCommitTsXid(TransactionId oldestXact);
/* XLOG stuff */ /* XLOG stuff */
#define COMMIT_TS_ZEROPAGE 0x00 #define COMMIT_TS_ZEROPAGE 0x00
......
...@@ -126,8 +126,8 @@ typedef struct VariableCacheData ...@@ -126,8 +126,8 @@ typedef struct VariableCacheData
/* /*
* These fields are protected by CommitTsLock * These fields are protected by CommitTsLock
*/ */
TransactionId oldestCommitTs; TransactionId oldestCommitTsXid;
TransactionId newestCommitTs; TransactionId newestCommitTsXid;
/* /*
* These fields are protected by ProcArrayLock. * These fields are protected by ProcArrayLock.
......
...@@ -46,9 +46,9 @@ typedef struct CheckPoint ...@@ -46,9 +46,9 @@ typedef struct CheckPoint
MultiXactId oldestMulti; /* cluster-wide minimum datminmxid */ MultiXactId oldestMulti; /* cluster-wide minimum datminmxid */
Oid oldestMultiDB; /* database with minimum datminmxid */ Oid oldestMultiDB; /* database with minimum datminmxid */
pg_time_t time; /* time stamp of checkpoint */ pg_time_t time; /* time stamp of checkpoint */
TransactionId oldestCommitTs; /* oldest Xid with valid commit TransactionId oldestCommitTsXid; /* oldest Xid with valid commit
* timestamp */ * timestamp */
TransactionId newestCommitTs; /* newest Xid with valid commit TransactionId newestCommitTsXid; /* newest Xid with valid commit
* timestamp */ * timestamp */
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment