]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: gracefully exit if newer gid replaces us by name
authorSage Weil <sage@inktank.com>
Fri, 18 Jan 2013 05:51:04 +0000 (21:51 -0800)
committerSage Weil <sage@inktank.com>
Fri, 18 Jan 2013 05:51:04 +0000 (21:51 -0800)
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 <sage@inktank.com>
src/mds/MDS.cc

index bd4bed91585c85b5d8102dd181fe055d63b408b6..e9f3ecc449d18cc562657831fbc8eb549bcc5403 100644 (file)
@@ -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();