agora inbox for pgpool-committers@postgresql.org  
help / color / mirror / Atom feed
From: Taiki Koshino <koshino@sraoss.co.jp>
To: pgpool-committers@lists.postgresql.org
Subject: pgpool: Convert pcp_worker die handler to flag-only.
Date: Wed, 16 Sep 2026 09:25:41 +0000
Message-ID: <E1x6ltd-0000000DD5n-2D6h@gothos.postgresql.org> (raw)

Convert pcp_worker die handler to flag-only.

die() (SIGTERM/SIGINT/SIGQUIT handler in the PCP worker child) directly
called ereport() and proceeded to exit logic from signal context. These
operations are not async-signal-safe, and ereport() in particular can
allocate memory or acquire locks that the main loop may already be
holding, risking corruption or a hang if the signal arrives at the
wrong point.

Convert die() to the canonical pgpool flag-only pattern used elsewhere
in this file. die() now only saves errno, records the signal number
into pcp_worker_shutdown_signal, sets pcp_worker_shutdown_request, and
restores errno before returning. The actual handling, logging the
shutdown request and performing the SIGTERM "smart shutdown" or
SIGINT/SIGQUIT immediate exit, is moved into the new
process_pcp_worker_shutdown_request(), which is called from the main
loop at safe points (before and after each PCP packet read).

Reported-by: Emond Papegaaij
Reported-by: Claude code
Author: Taiki Koshino <koshino@sraoss.co.jp>
Discussion: https://www.postgresql.org/message-id/OS9P286MB6486805F1222F8F50767639094AE2%40OS9P286MB6486.JPNP286...
Backpatch-through: v4.3

Branch
------
V4_3_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=8964c11f5691d1237d4ec4bd32ec0a295be4f...

Modified Files
--------------
src/pcp_con/pcp_worker.c | 53 ++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 44 insertions(+), 9 deletions(-)



view thread (6+ messages)

Message-ID: <E1x6ltd-0000000DD5n-2D6h@gothos.postgresql.org>
Permalink:  ../E1x6ltd-0000000DD5n-2D6h@gothos.postgresql.org/
Also on:    postgresql.org/message-id/E1x6ltd-0000000DD5n-2D6h@gothos.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgpool-committers@postgresql.org
  Cc: koshino@sraoss.co.jp, pgpool-committers@lists.postgresql.org
  Subject: Re: pgpool: Convert pcp_worker die handler to flag-only.
  In-Reply-To: <E1x6ltd-0000000DD5n-2D6h@gothos.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox