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

Commitac22929

Browse files
committed
Get rid of the dedicated latch for signaling the startup process.
This commit gets rid of the dedicated latch for signaling the startupprocess in favor of using its procLatch, since that comports betterwith possible generic signal handlers using that latch.Commit1e53fe0 changed background processes so that they use standardSIGHUP handler. Like that, this commit also makes the startup process usestandard SIGHUP handler to simplify the code.Author: Fujii MasaoReviewed-by: Bharath Rupireddy, Michael PaquierDiscussion:https://postgr.es/m/CALj2ACXPorUqePswDtOeM_s82v9RW32E1fYmOPZ5NuE+TWKj_A@mail.gmail.com
1 parent02d3322 commitac22929

File tree

2 files changed

+19
-34
lines changed

2 files changed

+19
-34
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ typedef struct XLogCtlData
682682
* WAL replay, if it is waiting for WAL to arrive or failover trigger file
683683
* to appear.
684684
*/
685-
LatchrecoveryWakeupLatch;
685+
Latch*recoveryWakeupLatch;
686686

687687
/*
688688
* During recovery, we keep a copy of the latest checkpoint record here.
@@ -5185,7 +5185,6 @@ XLOGShmemInit(void)
51855185
SpinLockInit(&XLogCtl->Insert.insertpos_lck);
51865186
SpinLockInit(&XLogCtl->info_lck);
51875187
SpinLockInit(&XLogCtl->ulsn_lck);
5188-
InitSharedLatch(&XLogCtl->recoveryWakeupLatch);
51895188
}
51905189

51915190
/*
@@ -6122,7 +6121,7 @@ recoveryApplyDelay(XLogReaderState *record)
61226121

61236122
while (true)
61246123
{
6125-
ResetLatch(&XLogCtl->recoveryWakeupLatch);
6124+
ResetLatch(MyLatch);
61266125

61276126
/* might change the trigger file's location */
61286127
HandleStartupProcInterrupts();
@@ -6146,7 +6145,7 @@ recoveryApplyDelay(XLogReaderState *record)
61466145
elog(DEBUG2,"recovery apply delay %ld seconds, %d milliseconds",
61476146
secs,microsecs /1000);
61486147

6149-
(void)WaitLatch(&XLogCtl->recoveryWakeupLatch,
6148+
(void)WaitLatch(MyLatch,
61506149
WL_LATCH_SET |WL_TIMEOUT |WL_EXIT_ON_PM_DEATH,
61516150
secs*1000L+microsecs /1000,
61526151
WAIT_EVENT_RECOVERY_APPLY_DELAY);
@@ -6474,11 +6473,11 @@ StartupXLOG(void)
64746473
}
64756474

64766475
/*
6477-
*Take ownership of the wakeup latch if we're goingtosleep during
6478-
* recovery.
6476+
*Advertise our latch that other processes can usetowake us up
6477+
*if we're going to sleep duringrecovery.
64796478
*/
64806479
if (ArchiveRecoveryRequested)
6481-
OwnLatch(&XLogCtl->recoveryWakeupLatch);
6480+
XLogCtl->recoveryWakeupLatch=&MyProc->procLatch;
64826481

64836482
/* Set up XLOG reader facility */
64846483
MemSet(&private,0,sizeof(XLogPageReadPrivate));
@@ -7489,11 +7488,11 @@ StartupXLOG(void)
74897488
ResetUnloggedRelations(UNLOGGED_RELATION_INIT);
74907489

74917490
/*
7492-
* We don't need the latch anymore. It's not strictly necessary todisown
7493-
* it, but let's do it for the sake of tidiness.
7491+
* We don't need the latch anymore. It's not strictly necessary toreset
7492+
* it to NULL, but let's do it for the sake of tidiness.
74947493
*/
74957494
if (ArchiveRecoveryRequested)
7496-
DisownLatch(&XLogCtl->recoveryWakeupLatch);
7495+
XLogCtl->recoveryWakeupLatch=NULL;
74977496

74987497
/*
74997498
* We are now done reading the xlog from stream. Turn off streaming
@@ -12242,12 +12241,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1224212241
wait_time=wal_retrieve_retry_interval-
1224312242
(secs*1000+usecs /1000);
1224412243

12245-
(void)WaitLatch(&XLogCtl->recoveryWakeupLatch,
12244+
(void)WaitLatch(MyLatch,
1224612245
WL_LATCH_SET |WL_TIMEOUT |
1224712246
WL_EXIT_ON_PM_DEATH,
1224812247
wait_time,
1224912248
WAIT_EVENT_RECOVERY_RETRIEVE_RETRY_INTERVAL);
12250-
ResetLatch(&XLogCtl->recoveryWakeupLatch);
12249+
ResetLatch(MyLatch);
1225112250
now=GetCurrentTimestamp();
1225212251
}
1225312252
last_fail_time=now;
@@ -12498,11 +12497,11 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1249812497
* to react to a trigger file promptly and to check if the
1249912498
* WAL receiver is still active.
1250012499
*/
12501-
(void)WaitLatch(&XLogCtl->recoveryWakeupLatch,
12500+
(void)WaitLatch(MyLatch,
1250212501
WL_LATCH_SET |WL_TIMEOUT |
1250312502
WL_EXIT_ON_PM_DEATH,
1250412503
5000L,WAIT_EVENT_RECOVERY_WAL_STREAM);
12505-
ResetLatch(&XLogCtl->recoveryWakeupLatch);
12504+
ResetLatch(MyLatch);
1250612505
break;
1250712506
}
1250812507

@@ -12674,7 +12673,7 @@ CheckPromoteSignal(void)
1267412673
void
1267512674
WakeupRecovery(void)
1267612675
{
12677-
SetLatch(&XLogCtl->recoveryWakeupLatch);
12676+
SetLatch(XLogCtl->recoveryWakeupLatch);
1267812677
}
1267912678

1268012679
/*

‎src/backend/postmaster/startup.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
/*
3838
* Flags set by interrupt handlers for later service in the redo loop.
3939
*/
40-
staticvolatilesig_atomic_tgot_SIGHUP= false;
4140
staticvolatilesig_atomic_tshutdown_requested= false;
4241
staticvolatilesig_atomic_tpromote_signaled= false;
4342

@@ -49,7 +48,6 @@ static volatile sig_atomic_t in_restore_command = false;
4948

5049
/* Signal handlers */
5150
staticvoidStartupProcTriggerHandler(SIGNAL_ARGS);
52-
staticvoidStartupProcSigHupHandler(SIGNAL_ARGS);
5351

5452

5553
/* --------------------------------
@@ -64,19 +62,7 @@ StartupProcTriggerHandler(SIGNAL_ARGS)
6462
intsave_errno=errno;
6563

6664
promote_signaled= true;
67-
WakeupRecovery();
68-
69-
errno=save_errno;
70-
}
71-
72-
/* SIGHUP: set flag to re-read config file at next convenient time */
73-
staticvoid
74-
StartupProcSigHupHandler(SIGNAL_ARGS)
75-
{
76-
intsave_errno=errno;
77-
78-
got_SIGHUP= true;
79-
WakeupRecovery();
65+
SetLatch(MyLatch);
8066

8167
errno=save_errno;
8268
}
@@ -91,7 +77,7 @@ StartupProcShutdownHandler(SIGNAL_ARGS)
9177
proc_exit(1);
9278
else
9379
shutdown_requested= true;
94-
WakeupRecovery();
80+
SetLatch(MyLatch);
9581

9682
errno=save_errno;
9783
}
@@ -137,9 +123,9 @@ HandleStartupProcInterrupts(void)
137123
/*
138124
* Process any requests or signals received recently.
139125
*/
140-
if (got_SIGHUP)
126+
if (ConfigReloadPending)
141127
{
142-
got_SIGHUP= false;
128+
ConfigReloadPending= false;
143129
StartupRereadConfig();
144130
}
145131

@@ -172,7 +158,7 @@ StartupProcessMain(void)
172158
/*
173159
* Properly accept or ignore signals the postmaster might send us.
174160
*/
175-
pqsignal(SIGHUP,StartupProcSigHupHandler);/* reload config file */
161+
pqsignal(SIGHUP,SignalHandlerForConfigReload);/* reload config file */
176162
pqsignal(SIGINT,SIG_IGN);/* ignore query cancel */
177163
pqsignal(SIGTERM,StartupProcShutdownHandler);/* request shutdown */
178164
/* SIGQUIT handler was already set up by InitPostmasterChild */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp