recoverd: reloadips should rebalance target nodes for new IPs
authorMartin Schwenke <martin@meltin.net>
Fri, 6 Sep 2013 01:21:10 +0000 (11:21 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 19 Sep 2013 02:54:31 +0000 (12:54 +1000)
Otherwise, if existing IPs are added to extra nodes (that have,
perhaps, been disconnected) then those IPs will not be rebalanced
across the extra nodes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit ceb30432a9a550778aed0b422a654fc5287b82a3)

ctdb/server/ctdb_takeover.c

index c6688864a4293ecfae9de68a7f63fc61673048e9..ecb0dbe5fabd558a8ff2566d9f660239254b6947 100644 (file)
@@ -4402,6 +4402,7 @@ static int ctdb_reloadips_child(struct ctdb_context *ctdb)
        struct timeval timeout;
        TDB_DATA data;
        struct ctdb_client_control_state *state;
+       bool first_add;
        int i, ret;
 
        CTDB_NO_MEMORY(ctdb, mem_ctx);
@@ -4475,6 +4476,7 @@ static int ctdb_reloadips_child(struct ctdb_context *ctdb)
        }
 
        /* Compare IPs between node and file for IPs to be added */
+       first_add = true;
        for (vnn = ctdb->vnn; vnn; vnn = vnn->next) {
                for (i = 0; i < ips->num; i++) {
                        if (ctdb_same_ip(&vnn->public_address,
@@ -4493,6 +4495,24 @@ static int ctdb_reloadips_child(struct ctdb_context *ctdb)
                        DEBUG(DEBUG_NOTICE,
                              ("New IP %s configured, adding it\n",
                               ctdb_addr_to_str(&vnn->public_address)));
+                       if (first_add) {
+                               uint32_t pnn = ctdb_get_pnn(ctdb);
+
+                               data.dsize = sizeof(pnn);
+                               data.dptr  = (uint8_t *)&pnn;
+
+                               ret = ctdb_client_send_message(
+                                       ctdb,
+                                       CTDB_BROADCAST_CONNECTED,
+                                       CTDB_SRVID_REBALANCE_NODE,
+                                       data);
+                               if (ret != 0) {
+                                       DEBUG(DEBUG_WARNING,
+                                             ("Failed to send message to force node reallocation - IPs may be unbalanced\n"));
+                               }
+
+                               first_add = false;
+                       }
 
                        ifaces = vnn->ifaces[0];
                        iface = 1;