]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Elector: do a trivial write on every election cycle 6091/head
authorSage Weil <sage@redhat.com>
Wed, 23 Sep 2015 14:58:01 +0000 (10:58 -0400)
committerNathan Cutler <ncutler@suse.com>
Sun, 27 Sep 2015 21:41:55 +0000 (23:41 +0200)
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 <sage@redhat.com>
(cherry picked from commit ef909ccbdc303cce8a39edef255325127832ff16)

    Conflicts:
src/mon/Elector.cc
            no MonitorDBStore::TransactionRef in firefly

src/mon/Elector.cc

index 2ee10f7b96039bb1baee5662db0ce306f513b8f1..debe58c551aba79ae878322812d9ea05eb4d611c 100644 (file)
@@ -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::Transaction t;
+    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;