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

Commit615704a

Browse files
committed
More fixes for shutdown during recovery.
1. If we receive a fast shutdown request while in the PM_STARTUP state,process it just as we would in PM_RECOVERY, PM_HOT_STANDBY, or PM_RUN.Without this change, an early fast shutdown followed by Hot Standby causesthe database to get stuck in a state where a shutdown is pending (so no newconnections are allowed) but the shutdown request is never processed unlesswe end Hot Standby and enter normal running.2. Avoid removing the backup label file when a smart or fast shutdown occursduring recovery. It makes sense to do this once we've reached normal running,since we must be taking a backup which now won't be valid. But duringrecovery we must be recovering from a previously taken backup, and any backuplabel file is needed to restart recovery from the right place.Fujii Masao and Robert Haas
1 parent20d6293 commit615704a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.608 2010/05/15 20:01:32 rhaas Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.609 2010/05/26 12:32:41 rhaas Exp $
4141
*
4242
* NOTES
4343
*
@@ -287,6 +287,8 @@ typedef enum
287287

288288
staticPMStatepmState=PM_INIT;
289289

290+
staticboolReachedNormalRunning= false;/* T if we've reached PM_RUN */
291+
290292
boolClientAuthInProgress= false;/* T during new-client
291293
* authentication */
292294

@@ -2168,7 +2170,7 @@ pmdie(SIGNAL_ARGS)
21682170
(errmsg("received smart shutdown request")));
21692171

21702172
if (pmState==PM_RUN||pmState==PM_RECOVERY||
2171-
pmState==PM_HOT_STANDBY)
2173+
pmState==PM_HOT_STANDBY||pmState==PM_STARTUP)
21722174
{
21732175
/* autovacuum workers are told to shut down immediately */
21742176
SignalAutovacWorkers(SIGTERM);
@@ -2370,6 +2372,7 @@ reaper(SIGNAL_ARGS)
23702372
* Startup succeeded, commence normal operations
23712373
*/
23722374
FatalError= false;
2375+
ReachedNormalRunning= true;
23732376
pmState=PM_RUN;
23742377

23752378
/*
@@ -3028,9 +3031,15 @@ PostmasterStateMachine(void)
30283031
{
30293032
/*
30303033
* Terminate backup mode to avoid recovery after a clean fast
3031-
* shutdown.
3034+
* shutdown. Since a backup can only be taken during normal
3035+
* running (and not, for example, while running under Hot Standby)
3036+
* it only makes sense to do this if we reached normal running.
3037+
* If we're still in recovery, the backup file is one we're
3038+
* recovering *from*, and we must keep it around so that recovery
3039+
* restarts from the right place.
30323040
*/
3033-
CancelBackup();
3041+
if (ReachedNormalRunning)
3042+
CancelBackup();
30343043

30353044
/* Normal exit from the postmaster is here */
30363045
ExitPostmaster(0);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp