From: Sage Weil Date: Thu, 17 Apr 2014 16:33:44 +0000 (-0700) Subject: mon: set leader commands prior to first election X-Git-Tag: v0.80-rc1~27^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1685%2Fhead;p=ceph.git mon: set leader commands prior to first election If we have just started and receive a command, we currently will reply with EINVAL because the leader commands are empty. Note that this race is very difficult to reach because the (old) peon needs to forward a command to the mon while it still thinks it has quorum, and the message needs to get sent after the leader mon has restarted and reset its connection but before it has declared a new election. To fix this, we should assume at startup time that our commands are valid. If it is an internal command that does not require quorum, that is fine. If it does require quorum, we will retry the command after the election completes and we will revalidate the command then. Fixes: #8132 Signed-off-by: Sage Weil --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 64be5ae64569..d24158a0ff80 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -198,6 +198,15 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s, assert(r); exited_quorum = ceph_clock_now(g_ceph_context); + + // assume our commands until we have an election. this only means + // we won't reply with EINVAL before the election; any command that + // actually matters will wait until we have quorum etc and then + // retry (and revalidate). + const MonCommand *cmds; + int cmdsize; + get_locally_supported_monitor_commands(&cmds, &cmdsize); + set_leader_supported_commands(cmds, cmdsize); } PaxosService *Monitor::get_paxos_service_by_name(const string& name)