]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Elector: force election epoch bump on start
authorSage Weil <sage@redhat.com>
Tue, 8 Aug 2017 22:43:22 +0000 (18:43 -0400)
committerSage Weil <sage@redhat.com>
Thu, 10 Aug 2017 16:22:49 +0000 (12:22 -0400)
We are generally careful when bumping the epoch so that we can join
existing rounds.  However, if we restart in the middle of an election,
and change versions, we need to be certain that our previous ACK (as
$version - 1) isn't accepted as truth for the restarted daemon (running
$version) keeping the same epoch.

The conservatism with bumping is to avoid spurious election cycles, but
mon restarts are more rare, and we need them here.

Fixes: http://tracker.ceph.com/issues/20949
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit ef425374250014393c1d432a3eda95179bb70537)

src/mon/Elector.cc

index 001fea95f3d5680f6a3e175c75ac0470294ed7b5..b7fde85528deff25ee46b52e537e213fa055c245 100644 (file)
@@ -35,9 +35,19 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, epoch_t epoch) {
 void Elector::init()
 {
   epoch = mon->store->get(Monitor::MONITOR_NAME, "election_epoch");
-  if (!epoch)
+  if (!epoch) {
+    dout(1) << "init, first boot, initializing epoch at 1 " << dendl;
     epoch = 1;
-  dout(1) << "init, last seen epoch " << epoch << dendl;
+  } else if (epoch % 2) {
+    dout(1) << "init, last seen epoch " << epoch
+           << ", mid-election, bumping" << dendl;
+    ++epoch;
+    auto t(std::make_shared<MonitorDBStore::Transaction>());
+    t->put(Monitor::MONITOR_NAME, "election_epoch", epoch);
+    mon->store->apply_transaction(t);
+  } else {
+    dout(1) << "init, last seen epoch " << epoch << dendl;
+  }
 }
 
 void Elector::shutdown()