Re: pg_receivewal and SIGTERM

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Christoph Berg <myon(at)debian(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_receivewal and SIGTERM
Date: 2022-08-16 10:22:44
Message-ID: EC39E60E-C8B6-4CDF-8BFA-E4D140446B41@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 15 Aug 2022, at 14:45, Christoph Berg <myon(at)debian(dot)org> wrote:

> The problem was that systemd's default KillSignal is SIGTERM, while
> pg_receivewal flushes the output compression buffers on SIGINT only.

Supporting SIGTERM here makes sense, especially given how systemd works.

> The attached patch makes it do the same for SIGTERM as well. (Most
> places in PG that install a SIGINT handler also install a SIGTERM
> handler already.)

Not really when it comes to utilities though; initdb, pg_dump and pg_test_fsync
seems to be the ones doing so. (That's probably mostly due to them not running
in a daemon-like way as what's discussed here.)

Do you think pg_recvlogical should support SIGTERM as well? (The signals which
it does trap should be added to the documentation which just now says "until
terminated by a signal" but that's a separate thing.)

pqsignal(SIGINT, sigint_handler);
+ pqsignal(SIGTERM, sigint_handler);
Tiny nitpick, I think we should rename sigint_handler to just sig_handler as it
does handle more than sigint.

In relation to this. Reading over this and looking around I realized that the
documentation for pg_waldump lacks a closing parenthesis on Ctrl+C so I will be
pushing the below to fix it:

--- a/doc/src/sgml/ref/pg_waldump.sgml
+++ b/doc/src/sgml/ref/pg_waldump.sgml
@@ -263,7 +263,7 @@ PostgreSQL documentation
<para>
If <application>pg_waldump</application> is terminated by signal
<systemitem>SIGINT</systemitem>
- (<keycombo action="simul"><keycap>Control</keycap><keycap>C</keycap></keycombo>,
+ (<keycombo action="simul"><keycap>Control</keycap><keycap>C</keycap></keycombo>),
the summary of the statistics computed is displayed up to the
termination point. This operation is not supported on
<productname>Windows</productname>.

--
Daniel Gustafsson https://vmware.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2022-08-16 10:41:43 Re: build remaining Flex files standalone
Previous Message Bharath Rupireddy 2022-08-16 10:16:00 Re: Patch proposal: New hooks in the connection path