From 294363c027ea0d9d4f62b8c4910b159a788ae831 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Sun, 13 Dec 2020 11:29:36 +0900 Subject: [PATCH] Fix segfault in child pgpool process in certain failback case. When previous primary node id is 0 and then it went down, restarted, re-attached without promotion. Then existing child process loses connection slot to node 0 and keeps on using it when node 0 comes back. This could result in segfault later on in the child process because there's no connection to node id 0. In summary we need to restart all pgppol children in this case. Per bug 672. --- src/main/pgpool_main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c index c1529f299..ca3a8f0d8 100644 --- a/src/main/pgpool_main.c +++ b/src/main/pgpool_main.c @@ -1635,7 +1635,18 @@ failover(void) * See bug 248 for more details. */ - if (STREAM && reqkind == NODE_UP_REQUEST && all_backend_down == false) + /* + * We also need to think about a case when the former primary node did + * not exist. In the case we need to restart all children as + * well. For example when previous primary node id is 0 and then it + * went down, restarted, re-attached without promotion. Then existing + * child process loses connection slot to node 0 and keeps on using it + * when node 0 comes back. This could result in segfault later on in + * the child process because there's no connection to node id 0. See + * bug 672 for more details. + */ + if (STREAM && reqkind == NODE_UP_REQUEST && all_backend_down == false && + Req_info->primary_node_id >= 0) { /* * The decision to restart/no-restart children for update status -- 2.39.5