Fix for inconsistent watchdog node_id problem in wd_cli
authorMuhammad Usama <m.usama@gmail.com>
Mon, 14 Dec 2020 14:50:08 +0000 (19:50 +0500)
committerMuhammad Usama <m.usama@gmail.com>
Mon, 14 Dec 2020 14:50:08 +0000 (19:50 +0500)
In watchdog node_id = 0 was reserved for local watchdog node
before 'simplifying watchdog configuration' patch, Now the watchdog
node IDshave become consistent across the cluster, but a couple of
placesĀ in the code were still expecting that node_id = 0 would
mean local node.

src/watchdog/watchdog.c
src/watchdog/wd_lifecheck.c

index 3811616613c262a3382700b9c22bb247b4d49544..4d88b567a5c5e61f5874d6fc4b422e89e3eb84cb 100644 (file)
@@ -2235,7 +2235,7 @@ fire_node_status_event(int nodeID, int nodeStatus)
 {
        WatchdogNode *wdNode = NULL;
 
-       if (nodeID == 0)                        /* this is reserved for local node */
+       if (g_cluster.localNode->pgpool_node_id == nodeID)
        {
                wdNode = g_cluster.localNode;
        }
@@ -3635,7 +3635,7 @@ static JsonNode * get_node_list_json(int id)
                /* add the array */
                jw_start_array(jNode, "WatchdogNodes");
 
-               if (id == 0)
+               if (id == g_cluster.localNode->pgpool_node_id)
                {
                        /* add the local node info */
                        add_nodeinfo_to_json(jNode, g_cluster.localNode);
index a08fb1bbf7b6ca265dbf9f9fc54f1c285abac6ce..4a87cfbc49f7442505a7cff0ffe12b121e39f126 100644 (file)
@@ -890,7 +890,7 @@ check_pgpool_status_by_query(void)
                                        continue;
                                node->nodeState = NODE_DEAD;
                                /* It's me! */
-                               if (i == 0)
+                               if (i == pool_config->pgpool_node_id)
                                        inform_node_status(node, "parent process is dead");
                                else
                                        inform_node_status(node, "unable to connect to node");