pg.ddx.io  pgpool-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgpool: Fix segfault when a watchdog sync changes the primary under run
6+ messages / 1 participants
[nested] [flat]

* pgpool: Fix segfault when a watchdog sync changes the primary under run
@ 2026-11-13 01:14 Tatsuo Ishii <ishii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tatsuo Ishii @ 2026-11-13 01:14 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

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_3_STABLE

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

Modified Files
--------------
src/main/pgpool_main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgpool: Fix segfault when a watchdog sync changes the primary under run
@ 2026-11-13 01:14 Tatsuo Ishii <ishii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tatsuo Ishii @ 2026-11-13 01:14 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

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_4_STABLE

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

Modified Files
--------------
src/main/pgpool_main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgpool: Fix segfault when a watchdog sync changes the primary under run
@ 2026-11-13 01:14 Tatsuo Ishii <ishii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tatsuo Ishii @ 2026-11-13 01:14 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

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(+)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgpool: Fix segfault when a watchdog sync changes the primary under run
@ 2026-11-13 01:14 Tatsuo Ishii <ishii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tatsuo Ishii @ 2026-11-13 01:14 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

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_6_STABLE

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

Modified Files
--------------
src/main/pgpool_main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgpool: Fix segfault when a watchdog sync changes the primary under run
@ 2026-11-13 01:14 Tatsuo Ishii <ishii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tatsuo Ishii @ 2026-11-13 01:14 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

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_7_STABLE

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

Modified Files
--------------
src/main/pgpool_main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgpool: Fix segfault when a watchdog sync changes the primary under run
@ 2026-11-13 01:14 Tatsuo Ishii <ishii@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Tatsuo Ishii @ 2026-11-13 01:14 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

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
------
master

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

Modified Files
--------------
src/main/pgpool_main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2026-11-13 01:14 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 01:14 pgpool: Fix segfault when a watchdog sync changes the primary under run Tatsuo Ishii <ishii@postgresql.org>
2026-11-13 01:14 pgpool: Fix segfault when a watchdog sync changes the primary under run Tatsuo Ishii <ishii@postgresql.org>
2026-11-13 01:14 pgpool: Fix segfault when a watchdog sync changes the primary under run Tatsuo Ishii <ishii@postgresql.org>
2026-11-13 01:14 pgpool: Fix segfault when a watchdog sync changes the primary under run Tatsuo Ishii <ishii@postgresql.org>
2026-11-13 01:14 pgpool: Fix segfault when a watchdog sync changes the primary under run Tatsuo Ishii <ishii@postgresql.org>
2026-11-13 01:14 pgpool: Fix segfault when a watchdog sync changes the primary under run Tatsuo Ishii <ishii@postgresql.org>

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