| From: | Taiki Koshino <koshino(at)sraoss(dot)co(dot)jp> |
|---|---|
| To: | pgpool-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgpool: Convert close_idle_connection (SIGUSR1) to flag-only handler wi |
| Date: | 2026-09-16 08:46:30 |
| Message-ID: | E1x6lHh-0000000Cu4L-43x9@gothos.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgpool-committers |
Convert close_idle_connection (SIGUSR1) to flag-only handler with main-loop processing.
The SIGUSR1 handler in the child process directly performed connection
cleanup, including pool_free_startup_packet() and pool_close(). These
operations are not async-signal-safe and can modify connection pool memory
while the main loop is using it.
In particular, SIGUSR1 can arrive while
connect_using_existing_connection() is replacing startup packet pointers.
This can cause the signal handler to free the same startup packet or
connection pool that the main loop is currently accessing.
This issue was reproduced in a local test environment, where sending
SIGUSR1 during startup packet replacement caused the child process to
terminate with a segmentation fault.
Changes:
Flag-only Signal Handler: Make close_idle_connection() only set a
volatile sig_atomic_t flag and return.
Main-loop Processing: Process the pending request from the child main loop
and perform connection cleanup outside the signal handler.
Direct Cleanup: Update the failover/failback restart path to call the
cleanup function directly.
Reported-by: Emond Papegaaij <emond(dot)papegaaij(at)gmail(dot)com>
Reported-by: Claude code
Author: Taiki Koshino <koshino(at)sraoss(dot)co(dot)jp>
Discussion: https://www.postgresql.org/message-id/TY4PR01MB1737480CA247F6CCBD87C958694C22%40TY4PR01MB17374.jpnprd01.prod.outlook.com
Backpatch-through: v4.3
Branch
------
V4_7_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=47c4735e827200fd10de45caf7aab957698375dd
Modified Files
--------------
src/protocol/child.c | 46 +++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 41 insertions(+), 5 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Taiki Koshino | 2026-09-16 08:46:48 | pgpool: Convert close_idle_connection (SIGUSR1) to flag-only handler wi |
| Previous Message | Taiki Koshino | 2026-09-16 08:46:09 | pgpool: Convert close_idle_connection (SIGUSR1) to flag-only handler wi |