pgpool2.git / summary / log / commit / refs
commit 567b102fdace2285b03e3d3439942be3eadd2d14
Author: Tatsuo Ishii <ishii@sraoss.co.jp>
Date: Mon Feb 08 11:30:18 2021 +0000
Fix watchdog leader sync process to start health check process.
When watchdog receives status change request from other watchdog node
and calls sync_backend_from_watchdog() to sync with status of leader
node, it forgot to start health check process. For example,
1) initial pgpool_status file indicates DB node 1 is down.
2) pgpool starts up but only starts health check process for DB node 0
because node 1 is in down status.
3) pcp_attach_node is issued to other than leader pgpool node.
4) leader node updates the node status for DB node 1 and other node
syncs the status. Since sync_backend_from_watchdog() does not start
health check process, only on pgpool leader node starts health
check process but other nodes do not.
To fix this starts health check process if necessary in
sync_backend_from_watchdog().
src/main/pgpool_main.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c
index bbe375990..cf5e0c328 100644
--- a/src/main/pgpool_main.c
+++ b/src/main/pgpool_main.c
@@ -2000,8 +2000,8 @@ failover(void)
{
ereport(LOG,
(errmsg("start health check process for host %s(%d)",
- BACKEND_INFO(node_id).backend_hostname,
- BACKEND_INFO(node_id).backend_port)));
+ BACKEND_INFO(i).backend_hostname,
+ BACKEND_INFO(i).backend_port)));
health_check_pids[i] = worker_fork_a_child(PT_HEALTH_CHECK, do_health_check_child, &i);
}
@@ -4123,6 +4123,20 @@ sync_backend_from_watchdog(void)
* Send restart request to worker child.
*/
kill(worker_pid, SIGUSR1);
+
+ /* Fork health check process if needed */
+ for (i = 0; i < NUM_BACKENDS; i++)
+ {
+ if (health_check_pids[i] == 0)
+ {
+ ereport(LOG,
+ (errmsg("start health check process for host %s(%d)",
+ BACKEND_INFO(i).backend_hostname,
+ BACKEND_INFO(i).backend_port)));
+
+ health_check_pids[i] = worker_fork_a_child(PT_HEALTH_CHECK, do_health_check_child, &i);
+ }
+ }
}
/*
[parent: 826062193ecb]