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

Commit51b5834

Browse files
committed
Provide options for postmaster to kill child processes with SIGABRT.
The postmaster normally sends SIGQUIT to force-terminate itschild processes after a child crash or immediate-stop request.If that doesn't result in child exit within a few seconds,we follow it up with SIGKILL. This patch provides GUC flagsthat allow either of these signals to be replaced with SIGABRT.On typically-configured Unix systems, that will result in acore dump being produced for each such child. This can beuseful for debugging problems, although it's not something you'dwant to have on in production due to the risk of disk spacebloat from lots of core files.The old postmaster -T switch, which sent SIGSTOP in place ofSIGQUIT, is changed to be the same as send_abort_for_crash.As far as I can tell from the code comments, the intent ofthat switch was just to block things for long enough to forcecore dumps manually, which seems like an unnecessary extra step.(Maybe at the time, there was no way to get most kernels toproduce core files with per-PID names, requiring manual corefile renaming after each one. But now it's surely the hard way.)I also took the opportunity to remove the old postmaster -n(skip shmem reinit) switch, which hasn't actually done anythingin decades, though the documentation still claimed it did.Discussion:https://postgr.es/m/2251016.1668797294@sss.pgh.pa.us
1 parente2933a6 commit51b5834

File tree

6 files changed

+134
-129
lines changed

6 files changed

+134
-129
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11500,6 +11500,62 @@ LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
1150011500
</listitem>
1150111501
</varlistentry>
1150211502

11503+
<varlistentry id="guc-send-abort-for-crash" xreflabel="send_abort_for_crash">
11504+
<term><varname>send_abort_for_crash</varname> (<type>boolean</type>)
11505+
<indexterm>
11506+
<primary><varname>send_abort_for_crash</varname> configuration parameter</primary>
11507+
</indexterm>
11508+
</term>
11509+
<listitem>
11510+
<para>
11511+
By default, after a backend crash the postmaster will stop remaining
11512+
child processes by sending them <systemitem>SIGQUIT</systemitem>
11513+
signals, which permits them to exit more-or-less gracefully. When
11514+
this option is set to <literal>on</literal>,
11515+
<systemitem>SIGABRT</systemitem> is sent instead. That normally
11516+
results in production of a core dump file for each such child
11517+
process.
11518+
This can be handy for investigating the states of other processes
11519+
after a crash. It can also consume lots of disk space in the event
11520+
of repeated crashes, so do not enable this on systems you are not
11521+
monitoring carefully.
11522+
Beware that no support exists for cleaning up the core file(s)
11523+
automatically.
11524+
This parameter can only be set in
11525+
the <filename>postgresql.conf</filename> file or on the server
11526+
command line.
11527+
</para>
11528+
</listitem>
11529+
</varlistentry>
11530+
11531+
<varlistentry id="guc-send-abort-for-kill" xreflabel="send_abort_for_kill">
11532+
<term><varname>send_abort_for_kill</varname> (<type>boolean</type>)
11533+
<indexterm>
11534+
<primary><varname>send_abort_for_kill</varname> configuration parameter</primary>
11535+
</indexterm>
11536+
</term>
11537+
<listitem>
11538+
<para>
11539+
By default, after attempting to stop a child process with
11540+
<systemitem>SIGQUIT</systemitem>, the postmaster will wait five
11541+
seconds and then send <systemitem>SIGKILL</systemitem> to force
11542+
immediate termination. When this option is set
11543+
to <literal>on</literal>, <systemitem>SIGABRT</systemitem> is sent
11544+
instead of <systemitem>SIGKILL</systemitem>. That normally results
11545+
in production of a core dump file for each such child process.
11546+
This can be handy for investigating the states
11547+
of <quote>stuck</quote> child processes. It can also consume lots
11548+
of disk space in the event of repeated crashes, so do not enable
11549+
this on systems you are not monitoring carefully.
11550+
Beware that no support exists for cleaning up the core file(s)
11551+
automatically.
11552+
This parameter can only be set in
11553+
the <filename>postgresql.conf</filename> file or on the server
11554+
command line.
11555+
</para>
11556+
</listitem>
11557+
</varlistentry>
11558+
1150311559
</variablelist>
1150411560
</sect1>
1150511561
<sect1 id="runtime-config-short">

‎doc/src/sgml/ref/postgres-ref.sgml

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -409,24 +409,6 @@ PostgreSQL documentation
409409
</listitem>
410410
</varlistentry>
411411

412-
<varlistentry>
413-
<term><option>-n</option></term>
414-
<listitem>
415-
<para>
416-
This option is for debugging problems that cause a server
417-
process to die abnormally. The ordinary strategy in this
418-
situation is to notify all other server processes that they
419-
must terminate and then reinitialize the shared memory and
420-
semaphores. This is because an errant server process could
421-
have corrupted some shared state before terminating. This
422-
option specifies that <command>postgres</command> will
423-
not reinitialize shared data structures. A knowledgeable
424-
system programmer can then use a debugger to examine shared
425-
memory and semaphore state.
426-
</para>
427-
</listitem>
428-
</varlistentry>
429-
430412
<varlistentry>
431413
<term><option>-O</option></term>
432414
<listitem>
@@ -466,14 +448,9 @@ PostgreSQL documentation
466448
This option is for debugging problems that cause a server
467449
process to die abnormally. The ordinary strategy in this
468450
situation is to notify all other server processes that they
469-
must terminate and then reinitialize the shared memory and
470-
semaphores. This is because an errant server process could
471-
have corrupted some shared state before terminating. This
472-
option specifies that <command>postgres</command> will
473-
stop all other server processes by sending the signal
474-
<literal>SIGSTOP</literal>, but will not cause them to
475-
terminate. This permits system programmers to collect core
476-
dumps from all server processes by hand.
451+
must terminate, by sending them <systemitem>SIGQUIT</systemitem>
452+
signals. With this option, <systemitem>SIGABRT</systemitem>
453+
will be sent instead, resulting in production of core dump files.
477454
</para>
478455
</listitem>
479456
</varlistentry>

‎src/backend/main/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,10 @@ help(const char *progname)
352352

353353
printf(_("\nDeveloper options:\n"));
354354
printf(_(" -f s|i|o|b|t|n|m|h forbid use of some plan types\n"));
355-
printf(_(" -n do not reinitialize shared memory after abnormal exit\n"));
356355
printf(_(" -O allow system table structure changes\n"));
357356
printf(_(" -P disable system indexes\n"));
358357
printf(_(" -t pa|pl|ex show timings after each query\n"));
359-
printf(_(" -T sendSIGSTOP to all backend processes if one dies\n"));
358+
printf(_(" -T sendSIGABRT to all backend processes if one dies\n"));
360359
printf(_(" -W NUM wait NUM seconds to allow attach from a debugger\n"));
361360

362361
printf(_("\nOptions for single-user mode:\n"));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp