Skip to content

Commit f37015a

Browse files
committed
Rename delayChkpt to delayChkptFlags.
Before commit 412ad7a, 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
1 parent 891624f commit f37015a

File tree

10 files changed

+57
-56
lines changed

10 files changed

+57
-56
lines changed

src/backend/access/transam/multixact.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,8 +3088,8 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
30883088
* crash/basebackup, even though the state of the data directory would
30893089
* require it.
30903090
*/
3091-
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) == 0);
3092-
MyProc->delayChkpt |= DELAY_CHKPT_START;
3091+
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) == 0);
3092+
MyProc->delayChkptFlags |= DELAY_CHKPT_START;
30933093

30943094
/* WAL log truncation */
30953095
WriteMTruncateXlogRec(newOldestMultiDB,
@@ -3115,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
31153115
/* Then offsets */
31163116
PerformOffsetsTruncation(oldestMulti, newOldestMulti);
31173117

3118-
MyProc->delayChkpt &= ~DELAY_CHKPT_START;
3118+
MyProc->delayChkptFlags &= ~DELAY_CHKPT_START;
31193119

31203120
END_CRIT_SECTION();
31213121
LWLockRelease(MultiXactTruncationLock);

src/backend/access/transam/twophase.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
479479
}
480480
proc->xid = xid;
481481
Assert(proc->xmin == InvalidTransactionId);
482-
proc->delayChkpt = 0;
482+
proc->delayChkptFlags = 0;
483483
proc->statusFlags = 0;
484484
proc->pid = 0;
485485
proc->databaseId = databaseid;
@@ -1173,11 +1173,11 @@ EndPrepare(GlobalTransaction gxact)
11731173
* Now writing 2PC state data to WAL. We let the WAL's CRC protection
11741174
* cover us, so no need to calculate a separate CRC.
11751175
*
1176-
* We have to set delayChkpt here, too; otherwise a checkpoint starting
1177-
* immediately after the WAL record is inserted could complete without
1178-
* fsync'ing our state file. (This is essentially the same kind of race
1179-
* condition as the COMMIT-to-clog-write case that RecordTransactionCommit
1180-
* uses delayChkpt for; see notes there.)
1176+
* We have to set DELAY_CHKPT_START here, too; otherwise a checkpoint
1177+
* starting immediately after the WAL record is inserted could complete
1178+
* without fsync'ing our state file. (This is essentially the same kind
1179+
* of race condition as the COMMIT-to-clog-write case that
1180+
* RecordTransactionCommit uses DELAY_CHKPT_START for; see notes there.)
11811181
*
11821182
* We save the PREPARE record's location in the gxact for later use by
11831183
* CheckPointTwoPhase.
@@ -1186,8 +1186,8 @@ EndPrepare(GlobalTransaction gxact)
11861186

11871187
START_CRIT_SECTION();
11881188

1189-
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) == 0);
1190-
MyProc->delayChkpt |= DELAY_CHKPT_START;
1189+
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) == 0);
1190+
MyProc->delayChkptFlags |= DELAY_CHKPT_START;
11911191

11921192
XLogBeginInsert();
11931193
for (record = records.head; record != NULL; record = record->next)
@@ -1230,7 +1230,7 @@ EndPrepare(GlobalTransaction gxact)
12301230
* checkpoint starting after this will certainly see the gxact as a
12311231
* candidate for fsyncing.
12321232
*/
1233-
MyProc->delayChkpt &= ~DELAY_CHKPT_START;
1233+
MyProc->delayChkptFlags &= ~DELAY_CHKPT_START;
12341234

12351235
/*
12361236
* Remember that we have this GlobalTransaction entry locked for us. If
@@ -1817,7 +1817,7 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
18171817
*
18181818
* Note that it isn't possible for there to be a GXACT with a
18191819
* prepare_end_lsn set prior to the last checkpoint yet is marked invalid,
1820-
* because of the efforts with delayChkpt.
1820+
* because of the efforts with delayChkptFlags.
18211821
*/
18221822
LWLockAcquire(TwoPhaseStateLock, LW_SHARED);
18231823
for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
@@ -2275,7 +2275,7 @@ ProcessTwoPhaseBuffer(TransactionId xid,
22752275
* RecordTransactionCommitPrepared
22762276
*
22772277
* This is basically the same as RecordTransactionCommit (q.v. if you change
2278-
* this function): in particular, we must set the delayChkpt flag to avoid a
2278+
* this function): in particular, we must set DELAY_CHKPT_START to avoid a
22792279
* race condition.
22802280
*
22812281
* We know the transaction made at least one XLOG entry (its PREPARE),
@@ -2308,8 +2308,8 @@ RecordTransactionCommitPrepared(TransactionId xid,
23082308
START_CRIT_SECTION();
23092309

23102310
/* See notes in RecordTransactionCommit */
2311-
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) == 0);
2312-
MyProc->delayChkpt |= DELAY_CHKPT_START;
2311+
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) == 0);
2312+
MyProc->delayChkptFlags |= DELAY_CHKPT_START;
23132313

23142314
/*
23152315
* Emit the XLOG commit record. Note that we mark 2PC commits as
@@ -2358,7 +2358,7 @@ RecordTransactionCommitPrepared(TransactionId xid,
23582358
TransactionIdCommitTree(xid, nchildren, children);
23592359

23602360
/* Checkpoint can proceed now */
2361-
MyProc->delayChkpt &= ~DELAY_CHKPT_START;
2361+
MyProc->delayChkptFlags &= ~DELAY_CHKPT_START;
23622362

23632363
END_CRIT_SECTION();
23642364

src/backend/access/transam/xact.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,14 +1387,14 @@ RecordTransactionCommit(void)
13871387
* RecordTransactionAbort. That's because loss of a transaction abort
13881388
* is noncritical; the presumption would be that it aborted, anyway.
13891389
*
1390-
* It's safe to change the delayChkpt flag of our own backend without
1391-
* holding the ProcArrayLock, since we're the only one modifying it.
1392-
* This makes checkpoint's determination of which xacts are delayChkpt
1393-
* a bit fuzzy, but it doesn't matter.
1390+
* It's safe to change the delayChkptFlags flag of our own backend
1391+
* without holding the ProcArrayLock, since we're the only one
1392+
* modifying it. This makes checkpoint's determination of which xacts
1393+
* are delaying the checkpoint a bit fuzzy, but it doesn't matter.
13941394
*/
1395-
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) == 0);
1395+
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) == 0);
13961396
START_CRIT_SECTION();
1397-
MyProc->delayChkpt |= DELAY_CHKPT_START;
1397+
MyProc->delayChkptFlags |= DELAY_CHKPT_START;
13981398

13991399
SetCurrentTransactionStopTimestamp();
14001400

@@ -1496,7 +1496,7 @@ RecordTransactionCommit(void)
14961496
*/
14971497
if (markXidCommitted)
14981498
{
1499-
MyProc->delayChkpt &= ~DELAY_CHKPT_START;
1499+
MyProc->delayChkptFlags &= ~DELAY_CHKPT_START;
15001500
END_CRIT_SECTION();
15011501
}
15021502

src/backend/access/transam/xlog.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6505,11 +6505,11 @@ CreateCheckPoint(int flags)
65056505
* protected by different locks, but again that seems best on grounds of
65066506
* minimizing lock contention.)
65076507
*
6508-
* A transaction that has not yet set delayChkpt when we look cannot be at
6509-
* risk, since he's not inserted his commit record yet; and one that's
6510-
* already cleared it is not at risk either, since he's done fixing clog
6511-
* and we will correctly flush the update below. So we cannot miss any
6512-
* xacts we need to wait for.
6508+
* A transaction that has not yet set delayChkptFlags when we look cannot
6509+
* be at risk, since it has not inserted its commit record yet; and one
6510+
* that's already cleared it is not at risk either, since it's done fixing
6511+
* clog and we will correctly flush the update below. So we cannot miss
6512+
* any xacts we need to wait for.
65136513
*/
65146514
vxids = GetVirtualXIDsDelayingChkpt(&nvxids, DELAY_CHKPT_START);
65156515
if (nvxids > 0)

src/backend/access/transam/xloginsert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ XLogSaveBufferForHint(Buffer buffer, bool buffer_std)
10111011
/*
10121012
* Ensure no checkpoint can change our view of RedoRecPtr.
10131013
*/
1014-
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) != 0);
1014+
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) != 0);
10151015

10161016
/*
10171017
* Update RedoRecPtr so that we can make the right decision

src/backend/catalog/storage.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ RelationTruncate(Relation rel, BlockNumber nblocks)
348348
* the blocks to not exist on disk at all, but not for them to have the
349349
* wrong contents.
350350
*/
351-
Assert((MyProc->delayChkpt & DELAY_CHKPT_COMPLETE) == 0);
352-
MyProc->delayChkpt |= DELAY_CHKPT_COMPLETE;
351+
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_COMPLETE) == 0);
352+
MyProc->delayChkptFlags |= DELAY_CHKPT_COMPLETE;
353353

354354
/*
355355
* We WAL-log the truncation before actually truncating, which means
@@ -397,7 +397,7 @@ RelationTruncate(Relation rel, BlockNumber nblocks)
397397
smgrtruncate(RelationGetSmgr(rel), forks, nforks, blocks);
398398

399399
/* We've done all the critical work, so checkpoints are OK now. */
400-
MyProc->delayChkpt &= ~DELAY_CHKPT_COMPLETE;
400+
MyProc->delayChkptFlags &= ~DELAY_CHKPT_COMPLETE;
401401

402402
/*
403403
* Update upper-level FSM pages to account for the truncation. This is

src/backend/storage/buffer/bufmgr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4021,7 +4021,7 @@ MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
40214021
{
40224022
XLogRecPtr lsn = InvalidXLogRecPtr;
40234023
bool dirtied = false;
4024-
bool delayChkpt = false;
4024+
bool delayChkptFlags = false;
40254025
uint32 buf_state;
40264026

40274027
/*
@@ -4071,9 +4071,9 @@ MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
40714071
* essential that CreateCheckPoint waits for virtual transactions
40724072
* rather than full transactionids.
40734073
*/
4074-
Assert((MyProc->delayChkpt & DELAY_CHKPT_START) == 0);
4075-
MyProc->delayChkpt |= DELAY_CHKPT_START;
4076-
delayChkpt = true;
4074+
Assert((MyProc->delayChkptFlags & DELAY_CHKPT_START) == 0);
4075+
MyProc->delayChkptFlags |= DELAY_CHKPT_START;
4076+
delayChkptFlags = true;
40774077
lsn = XLogSaveBufferForHint(buffer, buffer_std);
40784078
}
40794079

@@ -4105,8 +4105,8 @@ MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
41054105
buf_state |= BM_DIRTY | BM_JUST_DIRTIED;
41064106
UnlockBufHdr(bufHdr, buf_state);
41074107

4108-
if (delayChkpt)
4109-
MyProc->delayChkpt &= ~DELAY_CHKPT_START;
4108+
if (delayChkptFlags)
4109+
MyProc->delayChkptFlags &= ~DELAY_CHKPT_START;
41104110

41114111
if (dirtied)
41124112
{

src/backend/storage/ipc/procarray.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid)
700700
proc->xmin = InvalidTransactionId;
701701

702702
/* be sure this is cleared in abort */
703-
proc->delayChkpt = 0;
703+
proc->delayChkptFlags = 0;
704704

705705
proc->recoveryConflictPending = false;
706706

@@ -742,7 +742,7 @@ ProcArrayEndTransactionInternal(PGPROC *proc, TransactionId latestXid)
742742
proc->xmin = InvalidTransactionId;
743743

744744
/* be sure this is cleared in abort */
745-
proc->delayChkpt = 0;
745+
proc->delayChkptFlags = 0;
746746

747747
proc->recoveryConflictPending = false;
748748

@@ -929,7 +929,7 @@ ProcArrayClearTransaction(PGPROC *proc)
929929
proc->recoveryConflictPending = false;
930930

931931
Assert(!(proc->statusFlags & PROC_VACUUM_STATE_MASK));
932-
Assert(!proc->delayChkpt);
932+
Assert(!proc->delayChkptFlags);
933933

934934
/*
935935
* Need to increment completion count even though transaction hasn't
@@ -3059,19 +3059,20 @@ GetOldestSafeDecodingTransactionId(bool catalogOnly)
30593059
* delaying checkpoint because they have critical actions in progress.
30603060
*
30613061
* Constructs an array of VXIDs of transactions that are currently in commit
3062-
* critical sections, as shown by having specified delayChkpt bits set in their
3063-
* PGPROC.
3062+
* critical sections, as shown by having specified delayChkptFlags bits set
3063+
* in their PGPROC.
30643064
*
30653065
* Returns a palloc'd array that should be freed by the caller.
30663066
* *nvxids is the number of valid entries.
30673067
*
3068-
* Note that because backends set or clear delayChkpt without holding any lock,
3069-
* the result is somewhat indeterminate, but we don't really care. Even in
3070-
* a multiprocessor with delayed writes to shared memory, it should be certain
3071-
* that setting of delayChkpt will propagate to shared memory when the backend
3072-
* takes a lock, so we cannot fail to see a virtual xact as delayChkpt if
3073-
* it's already inserted its commit record. Whether it takes a little while
3074-
* for clearing of delayChkpt to propagate is unimportant for correctness.
3068+
* Note that because backends set or clear delayChkptFlags without holding any
3069+
* lock, the result is somewhat indeterminate, but we don't really care. Even
3070+
* in a multiprocessor with delayed writes to shared memory, it should be
3071+
* certain that setting of delayChkptFlags will propagate to shared memory
3072+
* when the backend takes a lock, so we cannot fail to see a virtual xact as
3073+
* delayChkptFlags if it's already inserted its commit record. Whether it
3074+
* takes a little while for clearing of delayChkptFlags to propagate is
3075+
* unimportant for correctness.
30753076
*/
30763077
VirtualTransactionId *
30773078
GetVirtualXIDsDelayingChkpt(int *nvxids, int type)
@@ -3094,7 +3095,7 @@ GetVirtualXIDsDelayingChkpt(int *nvxids, int type)
30943095
int pgprocno = arrayP->pgprocnos[index];
30953096
PGPROC *proc = &allProcs[pgprocno];
30963097

3097-
if ((proc->delayChkpt & type) != 0)
3098+
if ((proc->delayChkptFlags & type) != 0)
30983099
{
30993100
VirtualTransactionId vxid;
31003101

@@ -3138,7 +3139,7 @@ HaveVirtualXIDsDelayingChkpt(VirtualTransactionId *vxids, int nvxids, int type)
31383139

31393140
GET_VXID_FROM_PGPROC(vxid, *proc);
31403141

3141-
if ((proc->delayChkpt & type) != 0 &&
3142+
if ((proc->delayChkptFlags & type) != 0 &&
31423143
VirtualTransactionIdIsValid(vxid))
31433144
{
31443145
int i;

src/backend/storage/lmgr/proc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ InitProcess(void)
393393
MyProc->roleId = InvalidOid;
394394
MyProc->tempNamespaceId = InvalidOid;
395395
MyProc->isBackgroundWorker = IsBackgroundWorker;
396-
MyProc->delayChkpt = 0;
396+
MyProc->delayChkptFlags = 0;
397397
MyProc->statusFlags = 0;
398398
/* NB -- autovac launcher intentionally does not set IS_AUTOVACUUM */
399399
if (IsAutoVacuumWorkerProcess())
@@ -578,7 +578,7 @@ InitAuxiliaryProcess(void)
578578
MyProc->roleId = InvalidOid;
579579
MyProc->tempNamespaceId = InvalidOid;
580580
MyProc->isBackgroundWorker = IsBackgroundWorker;
581-
MyProc->delayChkpt = 0;
581+
MyProc->delayChkptFlags = 0;
582582
MyProc->statusFlags = 0;
583583
MyProc->lwWaiting = false;
584584
MyProc->lwWaitMode = 0;

src/include/storage/proc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ struct PGPROC
226226
pg_atomic_uint64 waitStart; /* time at which wait for lock acquisition
227227
* started */
228228

229-
int delayChkpt; /* for DELAY_CHKPT_* flags */
229+
int delayChkptFlags; /* for DELAY_CHKPT_* flags */
230230

231231
uint8 statusFlags; /* this backend's status flags, see PROC_*
232232
* above. mirrored in

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy