From: Tatsuo Ishii <ishii@postgresql.org>
To: pgpool-committers@lists.postgresql.org
Subject: pgpool: Fix segfault when a watchdog sync changes the primary under run
Date: Fri, 13 Nov 2026 01:14:38 +0000
Message-ID: <E1xRfsE-000000030zI-2ldg@gothos.postgresql.org> (raw)
Fix segfault when a watchdog sync changes the primary under running children.
sync_backend_from_watchdog() applies a failover performed by the leader
watchdog node: it updates the backend status, Req_info->primary_node_id and
Req_info->main_node_id, and only then kills and re-forks the children.
Unlike failover() it did not set Req_info->switching, so a child processing
a query meanwhile could get the new primary node from
pool_virtual_main_db_node_id(). If its session had no connection to that
node, for example because the node was down when the session started, the
child dereferenced a NULL connection slot (MAIN(backend)->fd in
read_packets_and_process()).
Set Req_info->switching while syncing, as failover() does, so children wait
for the sync to finish or to be killed. Requests registered while switching
is set do not wake up the main process, so raise the failover interrupt when
the sync ends with requests queued.
Author: Emond Papegaaij <emond.papegaaij@gmail.com>
Reported-by: Claude
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Backpatch-through: v4.3
Branch
------
V4_5_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=2db6100bd69fa42496106a3af07e4b7ea784b...
Modified Files
--------------
src/main/pgpool_main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgpool-committers@postgresql.org
Cc: ishii@postgresql.org
Subject: Re: pgpool: Fix segfault when a watchdog sync changes the primary under run
In-Reply-To: <E1xRfsE-000000030zI-2ldg@gothos.postgresql.org>
References: <E1xRfsE-000000030zI-2ldg@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox