Fix segfault in child pgpool process in certain failback case.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 13 Dec 2020 02:29:36 +0000 (11:29 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 13 Dec 2020 02:33:02 +0000 (11:33 +0900)
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

index c1529f299f662672c11d20e706c755bf2e15c16b..ca3a8f0d8595f83edfc4b7b16e40a5d9a850da70 100644 (file)
@@ -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