]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PGMonitor: reset in-core PGMap if on-disk format changes
authorSage Weil <sage@inktank.com>
Fri, 26 Jul 2013 22:25:12 +0000 (15:25 -0700)
committerSage Weil <sage@inktank.com>
Fri, 26 Jul 2013 22:25:30 +0000 (15:25 -0700)
We might have a sequence like:

- start mon, load pgmap 100
- sync
 - including a format upgrade at say v 150
- refresh
 - see format_version==1, and try read pgmap:101 as new format

This simply clears our in-memory state if we see that the format has
changed.  That will make update_from_paxos reload the latest and prevent
it from walking through the old and useless inc updates.

Note: this does not affect the auth monitor because we unconditionally
load the latest map in update_from_paxos on upgrade.  Also, the upgrade
there wasn't a format change--just a translation of cap strings from the
old to new style.

Fixes: #5764
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/mon/PGMonitor.cc
src/mon/PGMonitor.h
src/mon/PaxosService.cc
src/mon/PaxosService.h

index 648a8fe2384664ac98a1cd493151705a22c11ef9..d86cbe70c19fdeea19284302f753e2f99cf2c6b8 100644 (file)
@@ -255,6 +255,12 @@ void PGMonitor::update_from_paxos(bool *need_bootstrap)
   update_logger();
 }
 
+void PGMonitor::on_upgrade()
+{
+  dout(1) << __func__ << " discarding in-core PGMap" << dendl;
+  pg_map = PGMap();
+}
+
 void PGMonitor::upgrade_format()
 {
   unsigned current = 1;
index e8e1b4210aaaa091c9d7aed0929ae31de0eef48d..44015395e943e8eb6bce89ea5c56d37d444e1214 100644 (file)
@@ -60,6 +60,7 @@ private:
   void create_initial();
   void update_from_paxos(bool *need_bootstrap);
   void upgrade_format();
+  void on_upgrade();
   void post_paxos_update();
   void handle_osd_timeouts();
   void create_pending();  // prepare a new pending
index d6e67a1c4b4c0eba1741678cdadde6ff5b7cedf3..1b21689863bc6bb0f9ea8d52b91d40438ea6dd3b 100644 (file)
@@ -114,7 +114,13 @@ void PaxosService::refresh(bool *need_bootstrap)
   // update cached versions
   cached_first_committed = mon->store->get(get_service_name(), first_committed_name);
   cached_last_committed = mon->store->get(get_service_name(), last_committed_name);
-  format_version = get_value("format_version");
+
+  version_t new_format = get_value("format_version");
+  if (new_format != format_version) {
+    dout(1) << __func__ << " upgraded, format " << format_version << " -> " << new_format << dendl;
+    on_upgrade();
+  }
+  format_version = new_format;
 
   dout(10) << __func__ << dendl;
 
index 74d5a90494c87367996ba9f5be92ed6e224e61ac..5321bebcacefcc210a570ebe11276732049c5310 100644 (file)
@@ -458,6 +458,11 @@ public:
    */
   virtual void upgrade_format() { }
 
+  /**
+   * this is called when we detect the store has just upgraded underneath us
+   */
+  virtual void on_upgrade() {}
+
   /**
    * Called when the Paxos system enters a Leader election.
    *