Fix "no watchdog configuration for local pgpool node" error.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 13 Dec 2020 08:08:08 +0000 (17:08 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 13 Dec 2020 08:23:50 +0000 (17:23 +0900)
If watchdog is disabled and wd_port is not defined (thus it's 0, which
is the default config value), the error occurred while checking
configured watchdog nodes. If watchdog is disabled, the check should
not be performed. Back patch to V4.2 stable when watchdog local node
was introduced.

src/config/pool_config_variables.c

index 443347b076275895700b127a75e7879ec0e3c0b6..3b8a8daba0a82cdaeda80349656dfc859a3bf905 100644 (file)
@@ -4650,20 +4650,24 @@ config_post_processor(ConfigContext context, int elevel)
 
        /* Set the number of configured Watchdog nodes */
        g_pool_config.wd_nodes.num_wd = 0;
-       for (i = 0; i < MAX_WATCHDOG_NUM; i++)
+
+       if (g_pool_config.use_watchdog)
        {
-               WdNodeInfo *wdNode = &g_pool_config.wd_nodes.wd_node_info[i];
+               for (i = 0; i < MAX_WATCHDOG_NUM; i++)
+               {
+                       WdNodeInfo *wdNode = &g_pool_config.wd_nodes.wd_node_info[i];
 
-               if (i == g_pool_config.pgpool_node_id && wdNode->wd_port <= 0)
-        {
-            ereport(elevel,
-                    (errmsg("invalid watchdog configuration"),
-                     errdetail("no watchdog configuration for local pgpool node, pgpool node id: %d ", g_pool_config.pgpool_node_id)));
-            return false;
-        }
+                       if (i == g_pool_config.pgpool_node_id && wdNode->wd_port <= 0)
+                       {
+                               ereport(elevel,
+                                               (errmsg("invalid watchdog configuration"),
+                                                errdetail("no watchdog configuration for local pgpool node, pgpool node id: %d ", g_pool_config.pgpool_node_id)));
+                               return false;
+                       }
 
-               if (wdNode->wd_port > 0)
-                       g_pool_config.wd_nodes.num_wd = i + 1;
+                       if (wdNode->wd_port > 0)
+                               g_pool_config.wd_nodes.num_wd = i + 1;
+               }
        }
 
        /* Set configured heartbeat destination interfaces */