]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix monitor cluster contraction race
authorSage Weil <sage@inktank.com>
Tue, 21 Aug 2012 00:04:58 +0000 (17:04 -0700)
committerSage Weil <sage@inktank.com>
Tue, 21 Aug 2012 16:03:33 +0000 (09:03 -0700)
If we contract to 1 monitor, we win_standalone_election() without bumping
the election epoch.  Racing paxos updates can then reach us without being
ignored and trigger an assert:

mon/Paxos.cc: In function 'void Paxos::handle_accept(MMonPaxos*)' thread 7f85eae05700 time 2012-08-20 16:01:00.843937
mon/Paxos.cc: 468: FAILED assert(state == STATE_UPDATING)

Fixes: #3003
Reported-by: John Wilkins <john.wilkins@inktank.com>
Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/Elector.h
src/mon/Monitor.cc

index 377cb97ac13e3320fb12c80620346788387d8569..d81eb2397633589efcded86033bb2706480e7e2b 100644 (file)
@@ -145,7 +145,7 @@ class Elector {
    *
    * @param e Epoch to which we will update our epoch
    */
-  void bump_epoch(epoch_t e=0);
+  void bump_epoch(epoch_t e);
 
   /**
    * @defgroup Elector_h_callbacks Callbacks
@@ -353,6 +353,15 @@ class Elector {
    */
   epoch_t get_epoch() { return epoch; }
 
+  /**
+   * advance_epoch
+   *
+   * increase election epoch by 1
+   */
+  void advance_epoch() {
+    bump_epoch(epoch + 1);
+  }
+
   /**
    * Handle received messages.
    *
index 902d6d508f78a7db36fc0b5999c214cbfb0853a3..e92077bc8a34af38a2b3ac324e8a66faf8d97674 100644 (file)
@@ -929,6 +929,11 @@ void Monitor::start_election()
 void Monitor::win_standalone_election()
 {
   dout(1) << "win_standalone_election" << dendl;
+
+  // bump election epoch, in case the previous epoch included other
+  // monitors; we need to be able to make the distinction.
+  elector.advance_epoch();
+
   rank = monmap->get_rank(name);
   assert(rank == 0);
   set<int> q;