From: Jianyu Li Date: Wed, 15 Nov 2017 07:43:44 +0000 (+0800) Subject: make sure that MDBalancer uses heartbeat info from the same epoch X-Git-Tag: v12.2.5~43^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=71c7b1a67004e90db6ea43f9cf608253c84d7a40;p=ceph.git make sure that MDBalancer uses heartbeat info from the same epoch 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 (cherry picked from commit 591fd4970863ae51dad5e16be3cef24c1c6c92d6) --- diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index af1ee09b63c2..9ebf9066b7f1 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -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(); } }