| From: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
|---|---|
| To: | pgpool-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgpool: Fix segfault when a watchdog sync changes the primary under run |
| Date: | 2026-11-13 01:14:33 |
| Message-ID: | E1xRfs9-000000030sb-2qMg@gothos.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgpool-committers |
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(dot)papegaaij(at)gmail(dot)com>
Reported-by: Claude
Reviewed-by: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Backpatch-through: v4.3
Branch
------
V4_4_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=4bb2e86b2a56fdd24d3bb4fabf8703efc939fbce
Modified Files
--------------
src/main/pgpool_main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tatsuo Ishii | 2026-11-13 01:14:38 | pgpool: Fix segfault when a watchdog sync changes the primary under run |
| Previous Message | Tatsuo Ishii | 2026-11-13 01:14:28 | pgpool: Fix segfault when a watchdog sync changes the primary under run |