Fix Pgpool-II child process crash during shutdown.
authorTatsuo Ishii <ishii@postgresql.org>
Sat, 9 Nov 2024 08:42:46 +0000 (17:42 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Sat, 9 Nov 2024 08:49:06 +0000 (17:49 +0900)
commita34244bdb96734f1c3d6f39aaca160c3406cd4c4
tree9a4bf4aec794d9cda59781fa87a1a63957a06c83
parent33aff5cc4f986ecf59ade5eea58aa45a74144d20
Fix Pgpool-II child process crash during shutdown.

It is reported that pgpool child process crashes during shutdown.
[pgpool-general: 9261] Re: Segmentation fault during shutdown

The actual crash was in close_all_backend_connections().
close_all_backend_connections() was called because on_system_exit
registers child_will_go_down(). At the moment it seems pgpool child
had just started up and doing pool_init_cp(). The connection pool
object had not been completely initialized, that's cause of the crash.

To fix this, introduce a new static variable in child.c and set it
true when the connection pool object is initialized. In
child_will_go_down() it is checked and close_all_backend_connections()
is called only when the variable is set to true.

Problem reported and analyzed by: Emond Papegaaij
Backpatch-through: v4.2
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2024-November/001938.html
src/protocol/child.c