From: Sage Weil Date: Wed, 23 Sep 2015 14:58:01 +0000 (-0400) Subject: mon/Elector: do a trivial write on every election cycle X-Git-Tag: v9.1.0~76^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F6040%2Fhead;p=ceph.git mon/Elector: do a trivial write on every election cycle Currently we already do a small write when the *first* election in a round happens (to update the election epoch). If the backend happens to fail while we are already in the midst of elections, however, we may continue to call elections without verifying we are still writeable. Signed-off-by: Sage Weil --- diff --git a/src/mon/Elector.cc b/src/mon/Elector.cc index 5b1ef4e207a0..3bec0effa58a 100644 --- a/src/mon/Elector.cc +++ b/src/mon/Elector.cc @@ -78,8 +78,15 @@ void Elector::start() init(); // start by trying to elect me - if (epoch % 2 == 0) + if (epoch % 2 == 0) { bump_epoch(epoch+1); // odd == election cycle + } else { + // do a trivial db write just to ensure it is writeable. + MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction); + t->put(Monitor::MONITOR_NAME, "election_writeable_test", rand()); + int r = mon->store->apply_transaction(t); + assert(r >= 0); + } start_stamp = ceph_clock_now(g_ceph_context); electing_me = true; acked_me[mon->rank] = CEPH_FEATURES_ALL;