Re: pg_receivewal and SIGTERM

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Christoph Berg <myon(at)debian(dot)org>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_receivewal and SIGTERM
Date: 2022-08-16 16:33:59
Message-ID: CALj2ACW1LTGaBbhF=E0gmavPYsbNmGdpVu+S6vd3U+93mYnUsw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 16, 2022 at 7:26 PM Christoph Berg <myon(at)debian(dot)org> wrote:
>
> Re: Bharath Rupireddy
> > Don't we need a similar explanation [1] for pg_recvlogical docs?
> >
> > [1]
> > <para>
> > In the absence of fatal errors, <application>pg_receivewal</application>
> > - will run until terminated by the <systemitem>SIGINT</systemitem> signal
> > - (<keycombo action="simul"><keycap>Control</keycap><keycap>C</keycap></keycombo>).
> > + will run until terminated by the <systemitem>SIGINT</systemitem>
> > + (<keycombo action="simul"><keycap>Control</keycap><keycap>C</keycap></keycombo>)
> > + or <systemitem>SIGTERM</systemitem> signal.
>
> Coped that from pg_receivewal(1) now.

Thanks.

<application>pg_receivewal</application> will exit with status 0 when
- terminated by the <systemitem>SIGINT</systemitem> signal. (That is the
+ terminated by the <systemitem>SIGINT</systemitem> or
+ <systemitem>SIGTERM</systemitem> signal. (That is the
normal way to end it. Hence it is not an error.) For fatal errors or
other signals, the exit status will be nonzero.

Can we specify the reason in the docs why a SIGTERM causes (which
typically would cause a program to end with non-zero exit code)
pg_receivewal and pg_recvlogical exit with zero exit code? Having this
in the commit message would help developers but the documentation will
help users out there.

Thoughts?

[1]
pg_receivewal, pg_recvlogical: Exit cleanly on SIGTERM

In pg_receivewal, compressed output is only flushed on clean exits. The
reason to support SIGTERM here as well is that pg_receivewal might well
be running as a daemon, and systemd's default KillSignal is SIGTERM.

Since pg_recvlogical is also supposed to run as a daemon, teach it about
SIGTERM as well.

--
Bharath Rupireddy
RDS Open Source Databases: https://aws.amazon.com/rds/postgresql/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-08-16 16:34:23 pg_walinspect: ReadNextXLogRecord's first_record argument
Previous Message Andrew Dunstan 2022-08-16 16:32:30 Re: Add find_in_log() and advance_wal() perl functions to core test framework (?)