// running modules on the active mgr daemon.
std::map<std::string, std::string> services;
+ static MgrMap create_null_mgrmap() {
+ MgrMap null_map;
+ /* Use the largest epoch so it's always bigger than whatever the mgr has. */
+ null_map.epoch = std::numeric_limits<decltype(epoch)>::max();
+ return null_map;
+ }
+
epoch_t get_epoch() const { return epoch; }
epoch_t get_last_failure_osd_epoch() const { return last_failure_osd_epoch; }
const entity_addrvec_t& get_active_addrs() const { return active_addrs; }
pending_map.clients = clients;
updated = true;
}
+ } else if (m->get_available()) {
+ dout(4) << "mgr thinks it is active but it is not, dropping!" << dendl;
+ auto m = make_message<MMgrMap>(MgrMap::create_null_mgrmap());
+ mon.send_reply(op, m.detach());
+ return true;
} else if (pending_map.active_gid == 0) {
// There is no currently active daemon, select this one.
if (pending_map.standbys.count(m->get_gid())) {
pending_map.clients.clear();
pending_map.last_failure_osd_epoch = blocklist_epoch;
+ /* If we are dropping the active, we need to notify clients immediately.
+ * Additionally, avoid logical races with ::prepare_beacon which cannot
+ * accurately determine if a mgr is a standby or an old active.
+ */
+ force_immediate_propose();
+
// So that when new active mgr subscribes to mgrdigest, it will
// get an immediate response instead of waiting for next timer
cancel_timer();
getline(ss, rs);
if (r >= 0) {
- bool do_update = false;
- if (prefix == "mgr fail" && is_writeable()) {
- propose_pending();
- do_update = false;
- } else {
- do_update = true;
- }
// success.. delay reply
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, r, rs,
get_last_committed() + 1));
- return do_update;
} else {
// reply immediately
mon.reply_command(op, r, rs, rdata, get_last_committed());
- return false;
}
+
+ return r >= 0;
}
void MgrMonitor::init()
if (need_immediate_propose) {
dout(10) << __func__ << " forced immediate propose" << dendl;
- need_immediate_propose = false;
propose_pending();
return true;
}
// apply to paxos
proposing = true;
+ need_immediate_propose = false; /* reset whenever we propose */
/**
* Callback class used to mark us as active once a proposal finishes going
* through Paxos.