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

Commit595bc97

Browse files
committed
Fix autovacuum launcher shutdown sequence
It was previously possible to have the launcher re-execute its main loopbefore shutting down if some other signal was received or an erroroccurred after getting SIGTERM, as reported by Qingqing Zhou.While investigating, Tom Lane further noticed that if autovacuum hadbeen disabled in the config file, it would misbehave by trying to starta new worker instead of bailing out immediately -- it would consideritself as invoked in emergency mode.Fix both problems by checking the shutdown flag in a few more places.These problems have existed since autovacuum was introduced, sobackpatch all the way back.
1 parent248c096 commit595bc97

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

‎src/backend/postmaster/autovacuum.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ AutoVacLauncherMain(int argc, char *argv[])
515515
/* Now we can allow interrupts again */
516516
RESUME_INTERRUPTS();
517517

518+
/* if in shutdown mode, no need for anything further; just go away */
519+
if (got_SIGTERM)
520+
gotoshutdown;
521+
518522
/*
519523
* Sleep at least 1 second after any error. We don't want to be
520524
* filling the error logs as fast as we can.
@@ -528,10 +532,14 @@ AutoVacLauncherMain(int argc, char *argv[])
528532
/* must unblock signals before calling rebuild_database_list */
529533
PG_SETMASK(&UnBlockSig);
530534

531-
/* in emergency mode, just start a worker and go away */
535+
/*
536+
* In emergency mode, just start a worker (unless shutdown was requested)
537+
* and go away.
538+
*/
532539
if (!AutoVacuumingActive())
533540
{
534-
do_start_worker();
541+
if (!got_SIGTERM)
542+
do_start_worker();
535543
proc_exit(0);/* done */
536544
}
537545

@@ -546,7 +554,8 @@ AutoVacLauncherMain(int argc, char *argv[])
546554
*/
547555
rebuild_database_list(InvalidOid);
548556

549-
for (;;)
557+
/* loop until shutdown request */
558+
while (!got_SIGTERM)
550559
{
551560
structtimevalnap;
552561
TimestampTzcurrent_time=0;
@@ -758,6 +767,7 @@ AutoVacLauncherMain(int argc, char *argv[])
758767
}
759768

760769
/* Normal exit from the autovac launcher is here */
770+
shutdown:
761771
ereport(LOG,
762772
(errmsg("autovacuum launcher shutting down")));
763773
AutoVacuumShmem->av_launcherpid=0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp