standby_for_rank = MDSMap::MDS_MATCHED_ACTIVE;
beacon.init(mdsmap, want_state, standby_for_rank, standby_for_name);
- whoami = -1;
+ whoami = MDS_RANK_NONE;
messenger->set_myname(entity_name_t::MDS(whoami));
// schedule tick
dout(1) << "handle_mds_map i (" << addr
<< ") dne in the mdsmap, new instance has larger gid " << i.global_id
<< ", suicide" << dendl;
+ // Call suicide() rather than respawn() because if someone else
+ // has taken our ID, we don't want to keep restarting and
+ // fighting them for the ID.
suicide();
goto out;
}
void MDS::damaged()
{
+ assert(whoami != MDS_RANK_NONE);
+
set_want_state(MDSMap::STATE_DAMAGED);
monc->flush_log(); // Flush any clog error from before we were called
beacon.notify_health(this); // Include latest status in our swan song
respawn(); // Respawn into standby in case mon has other work for us
}
-void MDS::suicide()
+void MDS::suicide(bool fast)
{
assert(mds_lock.is_locked());
set_want_state(MDSMap::STATE_DNE); // whatever.
+ if (!fast && !mdsmap->is_dne_gid(mds_gid_t(monc->get_global_id()))) {
+ // Notify the MDSMonitor that we're dying, so that it doesn't have to
+ // wait for us to go laggy. Only do this if we're actually in the
+ // MDSMap, because otherwise the MDSMonitor will drop our message.
+ beacon.send_and_wait(1);
+ }
+
dout(1) << "suicide. wanted " << ceph_mds_state_name(want_state)
<< ", now " << ceph_mds_state_name(state) << dendl;
dout(0) << "respawn execv " << orig_argv[0]
<< " failed with " << cpp_strerror(errno) << dendl;
- suicide();
+ suicide(true);
}
void MDS::handle_write_error(int err)
* through cleaner scrub/repair mechanisms.
*/
void damaged();
- void suicide();
+
+ /**
+ * Terminate this daemon process.
+ *
+ * @param fast: if true, do not send a message to the mon before shutting
+ * down
+ */
+ void suicide(bool fast = false);
+
+ /**
+ * Start a new daemon process with the same command line parameters that
+ * this process was run with, then terminate this process
+ */
void respawn();
void handle_write_error(int err);