From: Sage Weil Date: Fri, 18 Jan 2013 05:51:04 +0000 (-0800) Subject: mds: gracefully exit if newer gid replaces us by name X-Git-Tag: v0.58~67^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dd7caf5f411696f8e7dc108270a8e85a34f3e80c;p=ceph.git mds: gracefully exit if newer gid replaces us by name If 'mds enforce unique name' is set, and another MDS with the same name kicks us out of the MDSMap, gracefully exit instead of respawning and fighting over our position. Signed-off-by: Sage Weil --- diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index bd4bed91585c..e9f3ecc449d1 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -903,6 +903,20 @@ void MDS::handle_mds_map(MMDSMap *m) if (want_state == MDSMap::STATE_BOOT) { dout(10) << "not in map yet" << dendl; } else { + // did i get kicked by someone else? + if (g_conf->mds_enforce_unique_name) { + if (uint64_t existing = mdsmap->find_mds_gid_by_name(name)) { + MDSMap::mds_info_t& i = mdsmap->get_info_gid(existing); + if (i.global_id > monc->get_global_id()) { + dout(1) << "handle_mds_map i (" << addr + << ") dne in the mdsmap, new instance has larger gid " << i.global_id + << ", suicide" << dendl; + suicide(); + goto out; + } + } + } + dout(1) << "handle_mds_map i (" << addr << ") dne in the mdsmap, respawning myself" << dendl; respawn();