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

Commit45f9b46

Browse files
committed
Avoid calling kill() in a postmaster signal handler.
This causes problems when the system load is high, per report from ZdenekKotala in <1250860954.1239.114.camel@localhost>; instead of calling killdirectly, have the signal handler set a flag which is checked in ServerLoop.This way, the handler can return before being called again by a subsequentsignal sent from the autovacuum launcher. Also, increase the sleep in thelauncher in this failure path to 1 second.Backpatch to 8.3, which is when the signalling between autovacuumlauncher/postmaster was introduced.Also, add a couple of ReleasePostmasterChildSlot calls in error paths; thispart backpatched to 8.4 which is when the child slot stuff was introduced.
1 parent9b708f1 commit45f9b46

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

‎src/backend/postmaster/autovacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
*
5757
* IDENTIFICATION
58-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.101 2009/08/12 20:53:30 tgl Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.102 2009/08/24 17:23:02 alvherre Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -653,7 +653,7 @@ AutoVacLauncherMain(int argc, char *argv[])
653653
* of a worker will continue to fail in the same way.
654654
*/
655655
AutoVacuumShmem->av_signal[AutoVacForkFailed]= false;
656-
pg_usleep(100000L);/*100ms */
656+
pg_usleep(1000000L);/*1s */
657657
SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_WORKER);
658658
continue;
659659
}

‎src/backend/postmaster/postmaster.c

Lines changed: 19 additions & 3 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.587 2009/08/07 05:58:55 heikki Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.588 2009/08/24 17:23:02 alvherre Exp $
4141
*
4242
* NOTES
4343
*
@@ -290,6 +290,8 @@ boolredirection_done = false;/* stderr redirected for syslogger? */
290290

291291
/* received START_AUTOVAC_LAUNCHER signal */
292292
staticvolatilesig_atomic_tstart_autovac_launcher= false;
293+
/* the launcher needs to be signalled to communicate some condition */
294+
staticvolatileboolavlauncher_needs_signal= false;
293295

294296
/*
295297
* State for assigning random salts and cancel keys.
@@ -1391,6 +1393,14 @@ ServerLoop(void)
13911393
if (PgStatPID==0&&pmState==PM_RUN)
13921394
PgStatPID=pgstat_start();
13931395

1396+
/* If we need to signal the autovacuum launcher, do so now */
1397+
if (avlauncher_needs_signal)
1398+
{
1399+
avlauncher_needs_signal= false;
1400+
if (AutoVacPID!=0)
1401+
kill(AutoVacPID,SIGUSR1);
1402+
}
1403+
13941404
/*
13951405
* Touch the socket and lock file every 58 minutes, to ensure that
13961406
* they are not removed by overzealous /tmp-cleaning tasks. We assume
@@ -3014,6 +3024,7 @@ BackendStartup(Port *port)
30143024
/* in parent, fork failed */
30153025
intsave_errno=errno;
30163026

3027+
(void)ReleasePostmasterChildSlot(bn->child_slot);
30173028
free(bn);
30183029
errno=save_errno;
30193030
ereport(LOG,
@@ -4343,6 +4354,7 @@ StartAutovacuumWorker(void)
43434354
* fork failed, fall through to report -- actual error message was
43444355
* logged by StartAutoVacWorker
43454356
*/
4357+
(void)ReleasePostmasterChildSlot(bn->child_slot);
43464358
free(bn);
43474359
}
43484360
else
@@ -4354,12 +4366,16 @@ StartAutovacuumWorker(void)
43544366
/*
43554367
* Report the failure to the launcher, if it's running. (If it's not, we
43564368
* might not even be connected to shared memory, so don't try to call
4357-
* AutoVacWorkerFailed.)
4369+
* AutoVacWorkerFailed.) Note that we also need to signal it so that it
4370+
* responds to the condition, but we don't do that here, instead waiting
4371+
* for ServerLoop to do it. This way we avoid a ping-pong signalling in
4372+
* quick succession between the autovac launcher and postmaster in case
4373+
* things get ugly.
43584374
*/
43594375
if (AutoVacPID!=0)
43604376
{
43614377
AutoVacWorkerFailed();
4362-
kill(AutoVacPID,SIGUSR1);
4378+
avlauncher_needs_signal= true;
43634379
}
43644380
}
43654381

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp