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

Commit40d4031

Browse files
committed
postmaster: Improve logging of signals sent by postmaster
Previously many, in some cases important, signals we never logged. In othercases the signal name was only included numerically.As part of this, change the debug log level the signal is logged at to DEBUG3,previously some where DEBUG2, some DEBUG4.Also move from direct use of kill() to signal the av launcher tosignal_child(). There doesn't seem to be a reason for directly using kill().Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>Discussion:https://postgr.es/m/kgng5nrvnlv335evmsuvpnh354rw7qyazl73kdysev2cr2v5zu@m3cfzxicm5kp
1 parent7148cbb commit40d4031

File tree

1 file changed

+43
-13
lines changed

1 file changed

+43
-13
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ ServerLoop(void)
16931693
{
16941694
avlauncher_needs_signal= false;
16951695
if (AutoVacLauncherPMChild!=NULL)
1696-
kill(AutoVacLauncherPMChild->pid,SIGUSR2);
1696+
signal_child(AutoVacLauncherPMChild,SIGUSR2);
16971697
}
16981698

16991699
#ifdefHAVE_PTHREAD_IS_THREADED_NP
@@ -3256,6 +3256,38 @@ LaunchMissingBackgroundProcesses(void)
32563256
maybe_start_bgworkers();
32573257
}
32583258

3259+
/*
3260+
* Return string representation of signal.
3261+
*
3262+
* Because this is only implemented for signals we already rely on in this
3263+
* file we don't need to deal with unimplemented or same-numeric-value signals
3264+
* (as we'd e.g. have to for EWOULDBLOCK / EAGAIN).
3265+
*/
3266+
staticconstchar*
3267+
pm_signame(intsignal)
3268+
{
3269+
#definePM_TOSTR_CASE(sym) case sym: return #sym
3270+
switch (signal)
3271+
{
3272+
PM_TOSTR_CASE(SIGABRT);
3273+
PM_TOSTR_CASE(SIGCHLD);
3274+
PM_TOSTR_CASE(SIGHUP);
3275+
PM_TOSTR_CASE(SIGINT);
3276+
PM_TOSTR_CASE(SIGKILL);
3277+
PM_TOSTR_CASE(SIGQUIT);
3278+
PM_TOSTR_CASE(SIGTERM);
3279+
PM_TOSTR_CASE(SIGUSR1);
3280+
PM_TOSTR_CASE(SIGUSR2);
3281+
default:
3282+
/* all signals sent by postmaster should be listed here */
3283+
Assert(false);
3284+
return"(unknown)";
3285+
}
3286+
#undef PM_TOSTR_CASE
3287+
3288+
return"";/* silence compiler */
3289+
}
3290+
32593291
/*
32603292
* Send a signal to a postmaster child process
32613293
*
@@ -3277,6 +3309,12 @@ signal_child(PMChild *pmchild, int signal)
32773309
{
32783310
pid_tpid=pmchild->pid;
32793311

3312+
ereport(DEBUG3,
3313+
(errmsg_internal("sending signal %d/%s to %s process with pid %d",
3314+
signal,pm_signame(signal),
3315+
GetBackendTypeDesc(pmchild->bkend_type),
3316+
(int)pmchild->pid)));
3317+
32803318
if (kill(pid,signal)<0)
32813319
elog(DEBUG3,"kill(%ld,%d) failed: %m", (long)pid,signal);
32823320
#ifdefHAVE_SETSID
@@ -3298,19 +3336,14 @@ signal_child(PMChild *pmchild, int signal)
32983336

32993337
/*
33003338
* Convenience function for killing a child process after a crash of some
3301-
* other child process. We log the action at a higher level than we would
3302-
* otherwise do, and we apply send_abort_for_crash to decide which signal
3303-
* to send. Normally it's SIGQUIT -- and most other comments in this file
3304-
* are written on the assumption that it is -- but developers might prefer
3305-
* to use SIGABRT to collect per-child core dumps.
3339+
* other child process. We apply send_abort_for_crash to decide which signal
3340+
* to send. Normally it's SIGQUIT -- and most other comments in this file are
3341+
* written on the assumption that it is -- but developers might prefer to use
3342+
* SIGABRT to collect per-child core dumps.
33063343
*/
33073344
staticvoid
33083345
sigquit_child(PMChild*pmchild)
33093346
{
3310-
ereport(DEBUG2,
3311-
(errmsg_internal("sending %s to process %d",
3312-
(send_abort_for_crash ?"SIGABRT" :"SIGQUIT"),
3313-
(int)pmchild->pid)));
33143347
signal_child(pmchild, (send_abort_for_crash ?SIGABRT :SIGQUIT));
33153348
}
33163349

@@ -3342,9 +3375,6 @@ SignalChildren(int signal, BackendTypeMask targetMask)
33423375
if (!btmask_contains(targetMask,bp->bkend_type))
33433376
continue;
33443377

3345-
ereport(DEBUG4,
3346-
(errmsg_internal("sending signal %d to %s process %d",
3347-
signal,GetBackendTypeDesc(bp->bkend_type), (int)bp->pid)));
33483378
signal_child(bp,signal);
33493379
signaled= true;
33503380
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp