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

Commit5df64f2

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 parente4f1e0d commit5df64f2

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
@@ -507,6 +507,10 @@ AutoVacLauncherMain(int argc, char *argv[])
507507
/* Now we can allow interrupts again */
508508
RESUME_INTERRUPTS();
509509

510+
/* if in shutdown mode, no need for anything further; just go away */
511+
if (got_SIGTERM)
512+
gotoshutdown;
513+
510514
/*
511515
* Sleep at least 1 second after any error. We don't want to be
512516
* filling the error logs as fast as we can.
@@ -542,10 +546,14 @@ AutoVacLauncherMain(int argc, char *argv[])
542546
SetConfigOption("default_transaction_isolation","read committed",
543547
PGC_SUSET,PGC_S_OVERRIDE);
544548

545-
/* in emergency mode, just start a worker and go away */
549+
/*
550+
* In emergency mode, just start a worker (unless shutdown was requested)
551+
* and go away.
552+
*/
546553
if (!AutoVacuumingActive())
547554
{
548-
do_start_worker();
555+
if (!got_SIGTERM)
556+
do_start_worker();
549557
proc_exit(0);/* done */
550558
}
551559

@@ -560,7 +568,8 @@ AutoVacLauncherMain(int argc, char *argv[])
560568
*/
561569
rebuild_database_list(InvalidOid);
562570

563-
for (;;)
571+
/* loop until shutdown request */
572+
while (!got_SIGTERM)
564573
{
565574
structtimevalnap;
566575
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