]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
make sure that MDBalancer uses heartbeat info from the same epoch
authorJianyu Li <joannyli@foxmail.com>
Wed, 15 Nov 2017 07:43:44 +0000 (15:43 +0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 6 Apr 2018 03:18:34 +0000 (20:18 -0700)
Currently mds saves the heartbeat info from others in mds_load, once the mds_load.size( ) equals mds number, it considers that have received all heartbeats info and start the rebalance work. However, after prep_rebalance returns, it doesn't clear the mds_load immediately, but wait until receives the next round hearbeat from mds0. If there are mutiple mds(e.g. greater than 2), there is a chance for one mds receiving the first next round heartbeat other than mds0 due to the network delay.

Signed-off-by: Jianyu Li <joannyli@tencent.com>
(cherry picked from commit 591fd4970863ae51dad5e16be3cef24c1c6c92d6)

src/mds/MDBalancer.cc

index af1ee09b63c2fc321c5bed4b1eaeedd5040dfc91..9ebf9066b7f1e54ec29831fb9cb19a8170b44f0d 100644 (file)
@@ -300,9 +300,11 @@ void MDBalancer::send_heartbeat()
     return;
   }
 
-  mds_load.clear();
-  if (mds->get_nodeid() == 0)
+  if (mds->get_nodeid() == 0) {
     beat_epoch++;
+   
+    mds_load.clear();
+  }
 
   // my load
   mds_load_t load = get_load(now);
@@ -367,8 +369,19 @@ void MDBalancer::handle_heartbeat(MHeartbeat *m)
     goto out;
   }
 
+  if (mds->get_nodeid() != 0 && m->get_beat() > beat_epoch) {
+    dout(10) << "receive next epoch " << m->get_beat() << " from mds." << who << " before mds0" << dendl;
+
+    beat_epoch = m->get_beat();
+    // clear the mds load info whose epoch is less than beat_epoch 
+    mds_load.clear();
+  }
+
   if (who == 0) {
-    dout(20) << " from mds0, new epoch" << dendl;
+    dout(20) << " from mds0, new epoch " << m->get_beat() << dendl;
+    if (beat_epoch != m->get_beat()) {
+      mds_load.clear();
+    }
     beat_epoch = m->get_beat();
     send_heartbeat();
 
@@ -400,6 +413,8 @@ void MDBalancer::handle_heartbeat(MHeartbeat *m)
                           << " : " << cpp_strerror(r);
       }
       prep_rebalance(m->get_beat());
+    
+      mds_load.clear();
     }
   }