]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: safely signal bootstrap from MonmapMonitor::update_from_paxos()
authorSage Weil <sage@inktank.com>
Fri, 31 May 2013 22:32:06 +0000 (15:32 -0700)
committerSage Weil <sage@inktank.com>
Wed, 19 Jun 2013 18:27:04 +0000 (11:27 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
17 files changed:
src/mon/AuthMonitor.cc
src/mon/AuthMonitor.h
src/mon/LogMonitor.cc
src/mon/LogMonitor.h
src/mon/MDSMonitor.cc
src/mon/MDSMonitor.h
src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/MonmapMonitor.cc
src/mon/MonmapMonitor.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h
src/mon/PGMonitor.cc
src/mon/PGMonitor.h
src/mon/Paxos.cc
src/mon/PaxosService.cc
src/mon/PaxosService.h

index b4f7681ed9a9362695a223430286c30239b2a5e8..5fa8644f3936865c1f0ac84f219e012663d88654 100644 (file)
@@ -111,7 +111,7 @@ void AuthMonitor::create_initial()
   pending_auth.push_back(inc);
 }
 
-void AuthMonitor::update_from_paxos()
+void AuthMonitor::update_from_paxos(bool *need_bootstrap)
 {
   dout(10) << __func__ << dendl;
   version_t version = get_version();
index 9368fcd861397faec6dc854da75349af1a660b02..5c17105692b7d26616b9f84c48088331faadf1d4 100644 (file)
@@ -130,7 +130,7 @@ private:
   void on_active();
   bool should_propose(double& delay);
   void create_initial();
-  void update_from_paxos();
+  void update_from_paxos(bool *need_bootstrap);
   void create_pending();  // prepare a new pending
   bool prepare_global_id(MMonGlobalID *m);
   void increase_max_global_id();
index ec4656d4ec4d83ef46d2634d6772f9d20cfb234c..54aea67eb8f22b73dc6cf03aef8b6e83e73a3b8b 100644 (file)
@@ -90,7 +90,7 @@ void LogMonitor::create_initial()
   pending_log.insert(pair<utime_t,LogEntry>(e.stamp, e));
 }
 
-void LogMonitor::update_from_paxos()
+void LogMonitor::update_from_paxos(bool *need_bootstrap)
 {
   dout(10) << __func__ << dendl;
   version_t version = get_version();
index 9eee758d47f20a098530aae2a6bfe6f24b74b78d..e20c81e227b4c944463b01ed380db9a48bae084a 100644 (file)
@@ -34,7 +34,7 @@ private:
   LogSummary pending_summary, summary;
 
   void create_initial();
-  void update_from_paxos();
+  void update_from_paxos(bool *need_bootstrap);
   void create_pending();  // prepare a new pending
   // propose pending update to peers
   void encode_pending(MonitorDBStore::Transaction *t);
index b5066c77cee09e16c7e68327d09f7aebc846b835..5f4582fdce3fbf3c8a7f8970e809a1c28f57b12f 100644 (file)
@@ -84,7 +84,7 @@ void MDSMonitor::create_initial()
 }
 
 
-void MDSMonitor::update_from_paxos()
+void MDSMonitor::update_from_paxos(bool *need_bootstrap)
 {
   version_t version = get_version();
   if (version == mdsmap.epoch)
index 52841cfff1060722909f3709ee7c8ac96d62ccea..b6ca84022afaa54eb1daf9ae240180afc07106ae 100644 (file)
@@ -68,7 +68,7 @@ class MDSMonitor : public PaxosService {
 
   // service methods
   void create_initial();
-  void update_from_paxos();
+  void update_from_paxos(bool *need_bootstrap);
   void create_pending(); 
   void encode_pending(MonitorDBStore::Transaction *t);
   // we don't require full versions; don't encode any.
index 7e2f3b8e34f47fdbed0770f970215e2d4e47a67e..2c655dea50856496d0128defc0f891fd9d5800c6 100644 (file)
@@ -522,7 +522,7 @@ void Monitor::init_paxos()
 
   // update paxos
   if (paxos->is_consistent())
-    refresh_from_paxos();
+    refresh_from_paxos(NULL);
 
   // init services
   for (int i = 0; i < PAXOS_NUM; ++i) {
@@ -532,11 +532,11 @@ void Monitor::init_paxos()
   }
 }
 
-void Monitor::refresh_from_paxos()
+void Monitor::refresh_from_paxos(bool *need_bootstrap)
 {
   dout(10) << __func__ << dendl;
   for (int i = 0; i < PAXOS_NUM; ++i) {
-    paxos_service[i]->refresh();
+    paxos_service[i]->refresh(need_bootstrap);
   }
 }
 
index a93884a636328f6421b046756b1c7bfd55b2f7a7..a9420ddefcaedd80e99c62b1a81577448d03f518 100644 (file)
@@ -1414,7 +1414,7 @@ public:
   int preinit();
   int init();
   void init_paxos();
-  void refresh_from_paxos();
+  void refresh_from_paxos(bool *need_bootstrap);
   void shutdown();
   void tick();
 
index 435ac77cd0548d6011671c9a193a92296d5bb623..cfc7bf7f29756c24973a464e84520361541e1721 100644 (file)
@@ -47,7 +47,7 @@ void MonmapMonitor::create_initial()
   pending_map.epoch = 1;
 }
 
-void MonmapMonitor::update_from_paxos()
+void MonmapMonitor::update_from_paxos(bool *need_bootstrap)
 {
   version_t version = get_version();
   if (version <= mon->monmap->get_epoch())
@@ -95,7 +95,10 @@ void MonmapMonitor::update_from_paxos()
       mon->monmap->decode(latest_bl);
   }
    */
-  bool need_restart = version != mon->monmap->get_epoch();  
+  if (need_bootstrap && version != mon->monmap->get_epoch()) {
+    dout(10) << " signaling that we need a bootstrap" << dendl;
+    *need_bootstrap = true;
+  }
 
   // read and decode
   monmap_bl.clear();
@@ -111,10 +114,6 @@ void MonmapMonitor::update_from_paxos()
     erase_mkfs(&t);
     mon->store->apply_transaction(t);
   }
-
-  if (need_restart) {
-    mon->bootstrap();
-  }
 }
 
 void MonmapMonitor::create_pending()
index 0690fb7409f354f739a58aafd58efeea3b66f5cf..198489d701772f7e5d1ddbe6353d745d13088ac3 100644 (file)
@@ -46,7 +46,7 @@ class MonmapMonitor : public PaxosService {
 
   void create_initial();
 
-  void update_from_paxos();
+  void update_from_paxos(bool *need_bootstrap);
 
   void create_pending();
 
index 04124f772a59b0501073be39103184e25f24bcae..f1728c0240d69dc07981dc07d47c0463c476d311 100644 (file)
@@ -105,7 +105,7 @@ void OSDMonitor::create_initial()
   newmap.encode(pending_inc.fullmap);
 }
 
-void OSDMonitor::update_from_paxos()
+void OSDMonitor::update_from_paxos(bool *need_bootstrap)
 {
   version_t version = get_version();
   if (version == osdmap.epoch)
index ef5ba77462b13d244e1e24fc71fb5e024e245658..ab0962c0a6b27ee2e585a6766f9b13300033f2cb 100644 (file)
@@ -145,7 +145,7 @@ private:
 public:  
   void create_initial();
 private:
-  void update_from_paxos();
+  void update_from_paxos(bool *need_bootstrap);
   void create_pending();  // prepare a new pending
   void encode_pending(MonitorDBStore::Transaction *t);
   virtual void encode_full(MonitorDBStore::Transaction *t);
index a8923662934c74da3f5285810ec99c62cdd7282c..a9f3c1b6c5db6960ae1e9d8df2b40f97d6422901 100644 (file)
@@ -149,7 +149,7 @@ void PGMonitor::create_initial()
   dout(10) << "create_initial -- creating initial map" << dendl;
 }
 
-void PGMonitor::update_from_paxos()
+void PGMonitor::update_from_paxos(bool *need_bootstrap)
 {
   version_t version = get_version();
   if (version == pg_map.version)
index e3afd0df24724dbc7608a6c3cdf4cb7138390119..b18b76b1288a3d5448d31d08b84fd5eb84061eb1 100644 (file)
@@ -51,7 +51,7 @@ private:
   PGMap::Incremental pending_inc;
 
   void create_initial();
-  void update_from_paxos();
+  void update_from_paxos(bool *need_bootstrap);
   void init();
   void handle_osd_timeouts();
   void create_pending();  // prepare a new pending
index 9c6d11345e8f6bedf592a64a0837b1eef84325c9..0d6d96de2e3acb40176e7439394a7250b6eaa90c 100644 (file)
@@ -715,7 +715,7 @@ void Paxos::handle_commit(MMonPaxos *commit)
 
   commit->put();
 
-  mon->refresh_from_paxos();
+  mon->refresh_from_paxos(NULL);
 
   finish_contexts(g_ceph_context, waiting_for_commit);
 }
@@ -786,7 +786,8 @@ void Paxos::finish_proposal()
   assert(mon->is_leader());
 
   // make sure we have the latest state loaded up
-  mon->refresh_from_paxos();
+  bool need_bootstrap = false;
+  mon->refresh_from_paxos(&need_bootstrap);
 
   // finish off the last proposal
   if (!proposals.empty()) {
@@ -821,6 +822,12 @@ void Paxos::finish_proposal()
   first_committed = get_store()->get(get_name(), "first_committed");
   last_committed = get_store()->get(get_name(), "last_committed");
 
+  if (need_bootstrap) {
+    dout(10) << " doing requested bootstrap" << dendl;
+    mon->bootstrap();
+    return;
+  }
+
   if (should_trim()) {
     trim();
   }
index 30b3b6e767c60079cdad567a2c558da370f1464d..b2a734a9b6c9a9629db9ad7e7750eff3161c0f25 100644 (file)
@@ -109,7 +109,7 @@ bool PaxosService::dispatch(PaxosServiceMessage *m)
   return true;
 }
 
-void PaxosService::refresh()
+void PaxosService::refresh(bool *need_bootstrap)
 {
   // update cached versions
   cached_first_committed = mon->store->get(get_service_name(), first_committed_name);
@@ -117,7 +117,7 @@ void PaxosService::refresh()
 
   dout(10) << __func__ << dendl;
 
-  update_from_paxos();
+  update_from_paxos(need_bootstrap);
 }
 
 
index ce232e559d3b6ba0eaaf54500cfcdadbe26bae56..4b0cb38b1adb96fd621c6da4a6c8d5d803bf5471 100644 (file)
@@ -314,7 +314,7 @@ public:
    */
   bool dispatch(PaxosServiceMessage *m);
 
-  void refresh();
+  void refresh(bool *need_bootstrap);
 
   /**
    * @defgroup PaxosService_h_override_funcs Functions that should be
@@ -338,7 +338,7 @@ public:
    *
    * @returns 'true' on success; 'false' otherwise.
    */
-  virtual void update_from_paxos() = 0;
+  virtual void update_from_paxos(bool *need_bootstrap) = 0;
 
   /**
    * Init on startup