| From: | Koshino Taiki <koshino(at)sraoss(dot)co(dot)jp> |
|---|---|
| To: | "pgpool-hackers(at)lists(dot)postgresql(dot)org" <pgpool-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Emond Papegaaij <emond(dot)papegaaij(at)gmail(dot)com> |
| Subject: | Convert pcp_worker die handler to flag-only. |
| Date: | 2026-08-26 09:21:31 |
| Message-ID: | OS9P286MB6486805F1222F8F50767639094AE2@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgpool-hackers |
I have reviewed the patch(029-pcp-worker-die-flag-only) from Emond.
It has also passed all regression tests.
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).
Note that in the originally provided patch, the signal was tracked with a single flag,
pcp_worker_shutdown_request, holding the signal number directly.
To align with 026-close-idle-connection-flag-only and 027-pcp-exit-handler-flag-only,
which keep the variable indicating that a signal has arrived separate
from the variable storing which signal it was, I split this into two variables here as well.
For reference, I'm also attaching the original patch(0001-fix-pcp-worker-die-flag-only.patch).
Also, regression tests passed after applying this together with the other
similar signal handler fixes, 026-close-idle-connection-flag-only and 027-pcp-exit-handler-flag-only.
However, 028-lifecheck-exit-handler-flag-only is failing due to a timeout
in the 004.watchdog test case, so 028 has not been posted to this ML yet.
Thank you Emond.
Taiki Koshino<koshino(at)sraoss(dot)co(dot)jp>
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Convert-pcp_worker-die-handler-to-flag-only.patch | application/octet-stream | 4.3 KB |
| 0001-fix-pcp-worker-die-flag-only.patch | application/octet-stream | 4.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tatsuo Ishii | 2026-08-26 23:44:02 | Stricter check for frontend message kind |
| Previous Message | Koshino Taiki | 2026-08-26 09:21:30 | Convert pcp_exit_handler and wakeup_handler_parent to flag-only. |