mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Rename delayChkpt to delayChkptFlags.
Before commit 412ad7a556, delayChkpt
was a Boolean. Now it's an integer. Extensions using it need to be
appropriately updated, so let's rename the field to make sure that
a hard compilation failure occurs.
Replacing delayChkpt with delayChkptFlags made a few comments extend
past 80 characters, so I reflowed them and changed some wording very
slightly.
The back-branches will need a different change to restore compatibility
with existing minor releases; this is just for master.
Per suggestion from Tom Lane.
Discussion: http://postgr.es/m/a7880f4d-1d74-582a-ada7-dad168d046d1@enterprisedb.com
This commit is contained in:
@@ -3088,8 +3088,8 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
|
||||
* crash/basebackup, even though the state of the data directory would
|
||||
* require it.
|
||||
*/
|
||||
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) == 0);
|
||||
MyProc->delayChkpt |= DELAY_CHKPT_START;
|
||||
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) == 0);
|
||||
MyProc->delayChkptFlags |= DELAY_CHKPT_START;
|
||||
|
||||
/* WAL log truncation */
|
||||
WriteMTruncateXlogRec(newOldestMultiDB,
|
||||
@@ -3115,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
|
||||
/* Then offsets */
|
||||
PerformOffsetsTruncation(oldestMulti, newOldestMulti);
|
||||
|
||||
MyProc->delayChkpt &= ~DELAY_CHKPT_START;
|
||||
MyProc->delayChkptFlags &= ~DELAY_CHKPT_START;
|
||||
|
||||
END_CRIT_SECTION();
|
||||
LWLockRelease(MultiXactTruncationLock);
|
||||
|
||||
@@ -479,7 +479,7 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
|
||||
}
|
||||
proc->xid = xid;
|
||||
Assert(proc->xmin == InvalidTransactionId);
|
||||
proc->delayChkpt = 0;
|
||||
proc->delayChkptFlags = 0;
|
||||
proc->statusFlags = 0;
|
||||
proc->pid = 0;
|
||||
proc->databaseId = databaseid;
|
||||
@@ -1173,11 +1173,11 @@ EndPrepare(GlobalTransaction gxact)
|
||||
* Now writing 2PC state data to WAL. We let the WAL's CRC protection
|
||||
* cover us, so no need to calculate a separate CRC.
|
||||
*
|
||||
* We have to set delayChkpt here, too; otherwise a checkpoint starting
|
||||
* immediately after the WAL record is inserted could complete without
|
||||
* fsync'ing our state file. (This is essentially the same kind of race
|
||||
* condition as the COMMIT-to-clog-write case that RecordTransactionCommit
|
||||
* uses delayChkpt for; see notes there.)
|
||||
* We have to set DELAY_CHKPT_START here, too; otherwise a checkpoint
|
||||
* starting immediately after the WAL record is inserted could complete
|
||||
* without fsync'ing our state file. (This is essentially the same kind
|
||||
* of race condition as the COMMIT-to-clog-write case that
|
||||
* RecordTransactionCommit uses DELAY_CHKPT_START for; see notes there.)
|
||||
*
|
||||
* We save the PREPARE record's location in the gxact for later use by
|
||||
* CheckPointTwoPhase.
|
||||
@@ -1186,8 +1186,8 @@ EndPrepare(GlobalTransaction gxact)
|
||||
|
||||
START_CRIT_SECTION();
|
||||
|
||||
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) == 0);
|
||||
MyProc->delayChkpt |= DELAY_CHKPT_START;
|
||||
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) == 0);
|
||||
MyProc->delayChkptFlags |= DELAY_CHKPT_START;
|
||||
|
||||
XLogBeginInsert();
|
||||
for (record = records.head; record != NULL; record = record->next)
|
||||
@@ -1230,7 +1230,7 @@ EndPrepare(GlobalTransaction gxact)
|
||||
* checkpoint starting after this will certainly see the gxact as a
|
||||
* candidate for fsyncing.
|
||||
*/
|
||||
MyProc->delayChkpt &= ~DELAY_CHKPT_START;
|
||||
MyProc->delayChkptFlags &= ~DELAY_CHKPT_START;
|
||||
|
||||
/*
|
||||
* Remember that we have this GlobalTransaction entry locked for us. If
|
||||
@@ -1817,7 +1817,7 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
|
||||
*
|
||||
* Note that it isn't possible for there to be a GXACT with a
|
||||
* prepare_end_lsn set prior to the last checkpoint yet is marked invalid,
|
||||
* because of the efforts with delayChkpt.
|
||||
* because of the efforts with delayChkptFlags.
|
||||
*/
|
||||
LWLockAcquire(TwoPhaseStateLock, LW_SHARED);
|
||||
for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
|
||||
@@ -2275,7 +2275,7 @@ ProcessTwoPhaseBuffer(TransactionId xid,
|
||||
* RecordTransactionCommitPrepared
|
||||
*
|
||||
* This is basically the same as RecordTransactionCommit (q.v. if you change
|
||||
* this function): in particular, we must set the delayChkpt flag to avoid a
|
||||
* this function): in particular, we must set DELAY_CHKPT_START to avoid a
|
||||
* race condition.
|
||||
*
|
||||
* We know the transaction made at least one XLOG entry (its PREPARE),
|
||||
@@ -2308,8 +2308,8 @@ RecordTransactionCommitPrepared(TransactionId xid,
|
||||
START_CRIT_SECTION();
|
||||
|
||||
/* See notes in RecordTransactionCommit */
|
||||
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) == 0);
|
||||
MyProc->delayChkpt |= DELAY_CHKPT_START;
|
||||
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) == 0);
|
||||
MyProc->delayChkptFlags |= DELAY_CHKPT_START;
|
||||
|
||||
/*
|
||||
* Emit the XLOG commit record. Note that we mark 2PC commits as
|
||||
@@ -2358,7 +2358,7 @@ RecordTransactionCommitPrepared(TransactionId xid,
|
||||
TransactionIdCommitTree(xid, nchildren, children);
|
||||
|
||||
/* Checkpoint can proceed now */
|
||||
MyProc->delayChkpt &= ~DELAY_CHKPT_START;
|
||||
MyProc->delayChkptFlags &= ~DELAY_CHKPT_START;
|
||||
|
||||
END_CRIT_SECTION();
|
||||
|
||||
|
||||
@@ -1387,14 +1387,14 @@ RecordTransactionCommit(void)
|
||||
* RecordTransactionAbort. That's because loss of a transaction abort
|
||||
* is noncritical; the presumption would be that it aborted, anyway.
|
||||
*
|
||||
* It's safe to change the delayChkpt flag of our own backend without
|
||||
* holding the ProcArrayLock, since we're the only one modifying it.
|
||||
* This makes checkpoint's determination of which xacts are delayChkpt
|
||||
* a bit fuzzy, but it doesn't matter.
|
||||
* It's safe to change the delayChkptFlags flag of our own backend
|
||||
* without holding the ProcArrayLock, since we're the only one
|
||||
* modifying it. This makes checkpoint's determination of which xacts
|
||||
* are delaying the checkpoint a bit fuzzy, but it doesn't matter.
|
||||
*/
|
||||
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) == 0);
|
||||
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) == 0);
|
||||
START_CRIT_SECTION();
|
||||
MyProc->delayChkpt |= DELAY_CHKPT_START;
|
||||
MyProc->delayChkptFlags |= DELAY_CHKPT_START;
|
||||
|
||||
SetCurrentTransactionStopTimestamp();
|
||||
|
||||
@@ -1496,7 +1496,7 @@ RecordTransactionCommit(void)
|
||||
*/
|
||||
if (markXidCommitted)
|
||||
{
|
||||
MyProc->delayChkpt &= ~DELAY_CHKPT_START;
|
||||
MyProc->delayChkptFlags &= ~DELAY_CHKPT_START;
|
||||
END_CRIT_SECTION();
|
||||
}
|
||||
|
||||
|
||||
@@ -6505,11 +6505,11 @@ CreateCheckPoint(int flags)
|
||||
* protected by different locks, but again that seems best on grounds of
|
||||
* minimizing lock contention.)
|
||||
*
|
||||
* A transaction that has not yet set delayChkpt when we look cannot be at
|
||||
* risk, since he's not inserted his commit record yet; and one that's
|
||||
* already cleared it is not at risk either, since he's done fixing clog
|
||||
* and we will correctly flush the update below. So we cannot miss any
|
||||
* xacts we need to wait for.
|
||||
* A transaction that has not yet set delayChkptFlags when we look cannot
|
||||
* be at risk, since it has not inserted its commit record yet; and one
|
||||
* that's already cleared it is not at risk either, since it's done fixing
|
||||
* clog and we will correctly flush the update below. So we cannot miss
|
||||
* any xacts we need to wait for.
|
||||
*/
|
||||
vxids = GetVirtualXIDsDelayingChkpt(&nvxids, DELAY_CHKPT_START);
|
||||
if (nvxids > 0)
|
||||
|
||||
@@ -1011,7 +1011,7 @@ XLogSaveBufferForHint(Buffer buffer, bool buffer_std)
|
||||
/*
|
||||
* Ensure no checkpoint can change our view of RedoRecPtr.
|
||||
*/
|
||||
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) != 0);
|
||||
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) != 0);
|
||||
|
||||
/*
|
||||
* Update RedoRecPtr so that we can make the right decision
|
||||
|
||||
Reference in New Issue
Block a user