summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuo Ishii2024-11-09 08:42:46 +0000
committerTatsuo Ishii2024-11-09 08:42:46 +0000
commit82d7132957fadd6faf4de1a794b2974c389e0ed2 (patch)
tree9e41927454ba9c6bbae5be41af7c9ef885cc1695 /src
parent08186df4ee67805230795e7a5da917dffc074e48 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/protocol/child.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/protocol/child.c b/src/protocol/child.c
index c12a5a2c1..ee7437770 100644
--- a/src/protocol/child.c
+++ b/src/protocol/child.c
@@ -141,6 +141,11 @@ bool stop_now = false;
#endif
/*
+ * If true, connection pool has been initialized.
+ */
+static bool connection_pool_initialized = false;
+
+/*
* child main loop
*/
void
@@ -223,6 +228,7 @@ do_child(int *fds)
{
child_exit(POOL_EXIT_AND_RESTART);
}
+ connection_pool_initialized = true;
/*
* Open pool_passwd in child process. This is necessary to avoid the file
@@ -1351,7 +1357,7 @@ child_will_go_down(int code, Datum arg)
}
/* let backend know now we are exiting */
- if (pool_connection_pool)
+ if (connection_pool_initialized)
close_all_backend_connections();
}