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

Commit38b2779

Browse files
committed
Avoid possible hang during smart shutdown.
If a smart shutdown occurs just as a child is starting up, and thechild subsequently becomes a walsender, there is a race condition:the postmaster might count the exstant backends, determine that thereis one normal backend, and wait for it to die off. Had the walsendertransition already occurred before the postmaster counted, it wouldhave proceeded with the shutdown.To fix this, have each child that transforms into a walsender kickthe postmaster just after doing so, so that the state machine iscertain to advance.Fujii Masao
1 parentd518d6a commit38b2779

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,8 +2890,8 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus)
28902890
/*
28912891
* Advance the postmaster's state machine and take actions as appropriate
28922892
*
2893-
* This is common code for pmdie()andreaper(), which receive the signals
2894-
* that might mean we need to change state.
2893+
* This is common code for pmdie(), reaper()andsigusr1_handler(), which
2894+
*receive the signalsthat might mean we need to change state.
28952895
*/
28962896
staticvoid
28972897
PostmasterStateMachine(void)
@@ -4284,6 +4284,13 @@ sigusr1_handler(SIGNAL_ARGS)
42844284
WalReceiverPID=StartWalReceiver();
42854285
}
42864286

4287+
if (CheckPostmasterSignal(PMSIGNAL_ADVANCE_STATE_MACHINE)&&
4288+
(pmState==PM_WAIT_BACKUP||pmState==PM_WAIT_BACKENDS))
4289+
{
4290+
/* Advance postmaster's state machine */
4291+
PostmasterStateMachine();
4292+
}
4293+
42874294
if (CheckPromoteSignal()&&StartupPID!=0&&
42884295
(pmState==PM_STARTUP||pmState==PM_RECOVERY||
42894296
pmState==PM_HOT_STANDBY||pmState==PM_WAIT_READONLY))

‎src/backend/replication/walsender.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ StartReplication(StartReplicationCmd * cmd)
361361
* after this.
362362
*/
363363
MarkPostmasterChildWalSender();
364+
SendPostmasterSignal(PMSIGNAL_ADVANCE_STATE_MACHINE);
364365

365366
/*
366367
* Check that we're logging enough information in the WAL for

‎src/include/storage/pmsignal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ typedef enum
2929
PMSIGNAL_START_AUTOVAC_LAUNCHER,/* start an autovacuum launcher */
3030
PMSIGNAL_START_AUTOVAC_WORKER,/* start an autovacuum worker */
3131
PMSIGNAL_START_WALRECEIVER,/* start a walreceiver */
32+
PMSIGNAL_ADVANCE_STATE_MACHINE,/* advance postmaster's state machine */
3233

3334
NUM_PMSIGNALS/* Must be last value of enum! */
3435
}PMSignalReason;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp