Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3ae406

Browse files
committed
Further tweaking of nomenclature in checkpointer.c.
Get rid of some more naming choices that only make sense if you know thatthis code used to be in the bgwriter, as well as some stray commentsreferencing the bgwriter.
1 parent6308ba0 commitd3ae406

File tree

1 file changed

+54
-53
lines changed

1 file changed

+54
-53
lines changed

‎src/backend/postmaster/checkpointer.c

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
* fill WAL segments; the checkpointer itself doesn't watch for the
1111
* condition.)
1212
*
13-
* The checkpointer is started by the postmaster as soon as the startup subprocess
14-
* finishes, or as soon as recovery begins if we are doing archive recovery.
15-
* It remains alive until the postmaster commands it to terminate.
16-
* Normal termination is by SIGUSR2, which instructs the checkpointer to execute
17-
* a shutdown checkpoint and then exit(0).(All backends must be stopped
18-
* before SIGUSR2 is issued!) Emergency termination is by SIGQUIT; like any
19-
* backend, the checkpointer will simply abort and exit on SIGQUIT.
13+
* The checkpointer is started by the postmaster as soon as the startup
14+
*subprocessfinishes, or as soon as recovery begins if we are doing archive
15+
*recovery.It remains alive until the postmaster commands it to terminate.
16+
* Normal termination is by SIGUSR2, which instructs the checkpointer to
17+
*executea shutdown checkpoint and then exit(0).(All backends must be
18+
*stoppedbefore SIGUSR2 is issued!) Emergency termination is by SIGQUIT;
19+
*like anybackend, the checkpointer will simply abort and exit on SIGQUIT.
2020
*
2121
* If the checkpointer exits unexpectedly, the postmaster treats that the same
2222
* as a backend crash: shared memory may be corrupted, so remaining backends
@@ -65,8 +65,8 @@
6565
*
6666
* The ckpt counters allow backends to watch for completion of a checkpoint
6767
* request they send. Here's how it works:
68-
** At start of a checkpoint, checkpointer reads (and clears) the request flags
69-
* and increments ckpt_started, while holding ckpt_lck.
68+
** At start of a checkpoint, checkpointer reads (and clears) the request
69+
*flagsand increments ckpt_started, while holding ckpt_lck.
7070
** On completion of a checkpoint, checkpointer sets ckpt_done to
7171
* equal ckpt_started.
7272
** On failure of a checkpoint, checkpointer increments ckpt_failed
@@ -95,7 +95,7 @@
9595
* by user backend processes. This counter should be wide enough that it
9696
* can't overflow during a single processing cycle. num_backend_fsync
9797
* counts the subset of those writes that also had to do their own fsync,
98-
* because thebackground writer failed to absorb their request.
98+
* because thecheckpointer failed to absorb their request.
9999
*
100100
* The requests array holds fsync requests sent by backends and not yet
101101
* absorbed by the checkpointer.
@@ -200,8 +200,8 @@ CheckpointerMain(void)
200200

201201
/*
202202
* If possible, make this process a group leader, so that the postmaster
203-
* can signal any child processes too.(checkpointer probably never has any
204-
* child processes, but for consistency we make all postmaster child
203+
* can signal any child processes too.(checkpointer probably never has
204+
*anychild processes, but for consistency we make all postmaster child
205205
* processes do this.)
206206
*/
207207
#ifdefHAVE_SETSID
@@ -216,9 +216,6 @@ CheckpointerMain(void)
216216
* system shutdown cycle, init will SIGTERM all processes at once.We
217217
* want to wait for the backends to exit, whereupon the postmaster will
218218
* tell us it's okay to shut down (via SIGUSR2).
219-
*
220-
* SIGUSR1 is presently unused; keep it spare in case someday we want this
221-
* process to participate in ProcSignal signalling.
222219
*/
223220
pqsignal(SIGHUP,ChkptSigHupHandler);/* set flag to read config file */
224221
pqsignal(SIGINT,ReqCheckpointHandler);/* request checkpoint */
@@ -302,12 +299,12 @@ CheckpointerMain(void)
302299
if (ckpt_active)
303300
{
304301
/* use volatile pointer to prevent code rearrangement */
305-
volatileCheckpointerShmemStruct*bgs=CheckpointerShmem;
302+
volatileCheckpointerShmemStruct*cps=CheckpointerShmem;
306303

307-
SpinLockAcquire(&bgs->ckpt_lck);
308-
bgs->ckpt_failed++;
309-
bgs->ckpt_done=bgs->ckpt_started;
310-
SpinLockRelease(&bgs->ckpt_lck);
304+
SpinLockAcquire(&cps->ckpt_lck);
305+
cps->ckpt_failed++;
306+
cps->ckpt_done=cps->ckpt_started;
307+
SpinLockRelease(&cps->ckpt_lck);
311308

312309
ckpt_active= false;
313310
}
@@ -455,7 +452,7 @@ CheckpointerMain(void)
455452
booldo_restartpoint;
456453

457454
/* use volatile pointer to prevent code rearrangement */
458-
volatileCheckpointerShmemStruct*bgs=CheckpointerShmem;
455+
volatileCheckpointerShmemStruct*cps=CheckpointerShmem;
459456

460457
/*
461458
* Check if we should perform a checkpoint or a restartpoint. As a
@@ -469,11 +466,11 @@ CheckpointerMain(void)
469466
* checkpoint we should perform, and increase the started-counter
470467
* to acknowledge that we've started a new checkpoint.
471468
*/
472-
SpinLockAcquire(&bgs->ckpt_lck);
473-
flags |=bgs->ckpt_flags;
474-
bgs->ckpt_flags=0;
475-
bgs->ckpt_started++;
476-
SpinLockRelease(&bgs->ckpt_lck);
469+
SpinLockAcquire(&cps->ckpt_lck);
470+
flags |=cps->ckpt_flags;
471+
cps->ckpt_flags=0;
472+
cps->ckpt_started++;
473+
SpinLockRelease(&cps->ckpt_lck);
477474

478475
/*
479476
* The end-of-recovery checkpoint is a real checkpoint that's
@@ -528,9 +525,9 @@ CheckpointerMain(void)
528525
/*
529526
* Indicate checkpoint completion to any waiting backends.
530527
*/
531-
SpinLockAcquire(&bgs->ckpt_lck);
532-
bgs->ckpt_done=bgs->ckpt_started;
533-
SpinLockRelease(&bgs->ckpt_lck);
528+
SpinLockAcquire(&cps->ckpt_lck);
529+
cps->ckpt_done=cps->ckpt_started;
530+
SpinLockRelease(&cps->ckpt_lck);
534531

535532
if (ckpt_performed)
536533
{
@@ -559,7 +556,11 @@ CheckpointerMain(void)
559556
CheckArchiveTimeout();
560557

561558
/*
562-
* Send off activity statistics to the stats collector
559+
* Send off activity statistics to the stats collector. (The reason
560+
* why we re-use bgwriter-related code for this is that the bgwriter
561+
* and checkpointer used to be just one process. It's probably not
562+
* worth the trouble to split the stats support into two independent
563+
* stats message types.)
563564
*/
564565
pgstat_send_bgwriter();
565566

@@ -651,13 +652,13 @@ ImmediateCheckpointRequested(void)
651652
{
652653
if (checkpoint_requested)
653654
{
654-
volatileCheckpointerShmemStruct*bgs=CheckpointerShmem;
655+
volatileCheckpointerShmemStruct*cps=CheckpointerShmem;
655656

656657
/*
657658
* We don't need to acquire the ckpt_lck in this case because we're
658659
* only looking at a single flag bit.
659660
*/
660-
if (bgs->ckpt_flags&CHECKPOINT_IMMEDIATE)
661+
if (cps->ckpt_flags&CHECKPOINT_IMMEDIATE)
661662
return true;
662663
}
663664
return false;
@@ -698,7 +699,7 @@ CheckpointWriteDelay(int flags, double progress)
698699
{
699700
got_SIGHUP= false;
700701
ProcessConfigFile(PGC_SIGHUP);
701-
/* updateglobalshmemstate for sync rep */
702+
/* update shmemcopies of config variables */
702703
UpdateSharedMemoryConfig();
703704
}
704705

@@ -708,7 +709,7 @@ CheckpointWriteDelay(int flags, double progress)
708709
CheckArchiveTimeout();
709710

710711
/*
711-
*Checkpoint sleep used to be connected to bgwriter_delay at 200ms.
712+
*This sleep used to be connected to bgwriter_delay, typically 200ms.
712713
* That resulted in more frequent wakeups if not much work to do.
713714
* Checkpointer and bgwriter are no longer related so take the Big Sleep.
714715
*/
@@ -894,7 +895,7 @@ ReqShutdownHandler(SIGNAL_ARGS)
894895

895896
/*
896897
* CheckpointerShmemSize
897-
*Compute space needed forbgwriter-related shared memory
898+
*Compute space needed forcheckpointer-related shared memory
898899
*/
899900
Size
900901
CheckpointerShmemSize(void)
@@ -913,15 +914,15 @@ CheckpointerShmemSize(void)
913914

914915
/*
915916
* CheckpointerShmemInit
916-
*Allocate and initializebgwriter-related shared memory
917+
*Allocate and initializecheckpointer-related shared memory
917918
*/
918919
void
919920
CheckpointerShmemInit(void)
920921
{
921922
boolfound;
922923

923924
CheckpointerShmem= (CheckpointerShmemStruct*)
924-
ShmemInitStruct("Background Writer Data",
925+
ShmemInitStruct("Checkpointer Data",
925926
CheckpointerShmemSize(),
926927
&found);
927928

@@ -955,7 +956,7 @@ void
955956
RequestCheckpoint(intflags)
956957
{
957958
/* use volatile pointer to prevent code rearrangement */
958-
volatileCheckpointerShmemStruct*bgs=CheckpointerShmem;
959+
volatileCheckpointerShmemStruct*cps=CheckpointerShmem;
959960
intntries;
960961
intold_failed,
961962
old_started;
@@ -989,13 +990,13 @@ RequestCheckpoint(int flags)
989990
* a "stronger" request by another backend. The flag senses must be
990991
* chosen to make this work!
991992
*/
992-
SpinLockAcquire(&bgs->ckpt_lck);
993+
SpinLockAcquire(&cps->ckpt_lck);
993994

994-
old_failed=bgs->ckpt_failed;
995-
old_started=bgs->ckpt_started;
996-
bgs->ckpt_flags |=flags;
995+
old_failed=cps->ckpt_failed;
996+
old_started=cps->ckpt_started;
997+
cps->ckpt_flags |=flags;
997998

998-
SpinLockRelease(&bgs->ckpt_lck);
999+
SpinLockRelease(&cps->ckpt_lck);
9991000

10001001
/*
10011002
* Send signal to request checkpoint. It's possible that the checkpointer
@@ -1043,9 +1044,9 @@ RequestCheckpoint(int flags)
10431044
/* Wait for a new checkpoint to start. */
10441045
for (;;)
10451046
{
1046-
SpinLockAcquire(&bgs->ckpt_lck);
1047-
new_started=bgs->ckpt_started;
1048-
SpinLockRelease(&bgs->ckpt_lck);
1047+
SpinLockAcquire(&cps->ckpt_lck);
1048+
new_started=cps->ckpt_started;
1049+
SpinLockRelease(&cps->ckpt_lck);
10491050

10501051
if (new_started!=old_started)
10511052
break;
@@ -1061,10 +1062,10 @@ RequestCheckpoint(int flags)
10611062
{
10621063
intnew_done;
10631064

1064-
SpinLockAcquire(&bgs->ckpt_lck);
1065-
new_done=bgs->ckpt_done;
1066-
new_failed=bgs->ckpt_failed;
1067-
SpinLockRelease(&bgs->ckpt_lck);
1065+
SpinLockAcquire(&cps->ckpt_lck);
1066+
new_done=cps->ckpt_done;
1067+
new_failed=cps->ckpt_failed;
1068+
SpinLockRelease(&cps->ckpt_lck);
10681069

10691070
if (new_done-new_started >=0)
10701071
break;
@@ -1178,7 +1179,7 @@ ForwardFsyncRequest(RelFileNodeBackend rnode, ForkNumber forknum,
11781179
staticbool
11791180
CompactCheckpointerRequestQueue(void)
11801181
{
1181-
structBgWriterSlotMapping
1182+
structCheckpointerSlotMapping
11821183
{
11831184
CheckpointerRequestrequest;
11841185
intslot;
@@ -1197,7 +1198,7 @@ CompactCheckpointerRequestQueue(void)
11971198
/* Initialize temporary hash table */
11981199
MemSet(&ctl,0,sizeof(ctl));
11991200
ctl.keysize=sizeof(CheckpointerRequest);
1200-
ctl.entrysize=sizeof(structBgWriterSlotMapping);
1201+
ctl.entrysize=sizeof(structCheckpointerSlotMapping);
12011202
ctl.hash=tag_hash;
12021203
htab=hash_create("CompactCheckpointerRequestQueue",
12031204
CheckpointerShmem->num_requests,
@@ -1223,7 +1224,7 @@ CompactCheckpointerRequestQueue(void)
12231224
for (n=0;n<CheckpointerShmem->num_requests;++n)
12241225
{
12251226
CheckpointerRequest*request;
1226-
structBgWriterSlotMapping*slotmap;
1227+
structCheckpointerSlotMapping*slotmap;
12271228
boolfound;
12281229

12291230
request=&CheckpointerShmem->requests[n];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp