From: Sage Weil Date: Wed, 16 Nov 2011 18:54:59 +0000 (-0800) Subject: mon: always load stashed version when version doesn't match X-Git-Tag: v0.39~51 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b425f6d6ceaa18d8cddb3f579d7c18bfb8b8d93a;p=ceph-ci.git mon: always load stashed version when version doesn't match The slurp process can happen after the monitor has started and has some in-memory version of the state, and that process may wipe out old incrementals and change the stashed version. That means that in update_from_paxos, we need to pull the stashed version if it doesn't match what we currently have or else we may not have the incrementals we need to get up to date. This simplifies and cleans up that code a bit so it is not specific to monitor startup. Signed-off-by: Sage Weil --- diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 001a2c4ac2e..6f572565322 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -111,25 +111,22 @@ void AuthMonitor::create_initial() bool AuthMonitor::update_from_paxos() { - dout(10) << "AuthMonitor::update_from_paxos()" << dendl; + dout(10) << "update_from_paxos()" << dendl; version_t paxosv = paxos->get_version(); version_t keys_ver = mon->key_server.get_ver(); if (paxosv == keys_ver) return true; assert(paxosv >= keys_ver); - if (keys_ver == 0 && paxosv > 0) { - // startup: just load latest full map + if (keys_ver != paxos->get_latest_version()) { bufferlist latest; version_t v = paxos->get_latest(latest); - if (v) { - dout(7) << "update_from_paxos startup: loading summary e" << v << dendl; - bufferlist::iterator p = latest.begin(); - __u8 v; - ::decode(v, p); - ::decode(max_global_id, p); - ::decode(mon->key_server, p); - } + dout(7) << "update_from_paxos loading summary e" << v << dendl; + bufferlist::iterator p = latest.begin(); + __u8 struct_v; + ::decode(struct_v, p); + ::decode(max_global_id, p); + ::decode(mon->key_server, p); } // walk through incrementals diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 5983e497d8c..17608e96092 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -104,15 +104,12 @@ bool LogMonitor::update_from_paxos() bufferlist blogerr; bufferlist blogsec; - if (summary.version == 0 && paxosv > 0) { - // startup: just load latest full map + if (summary.version != paxos->get_latest_version()) { bufferlist latest; version_t v = paxos->get_latest(latest); - if (v) { - dout(7) << "update_from_paxos startup: loading summary e" << v << dendl; - bufferlist::iterator p = latest.begin(); - ::decode(summary, p); - } + dout(7) << "update_from_paxos loading summary e" << v << dendl; + bufferlist::iterator p = latest.begin(); + ::decode(summary, p); } // walk through incrementals diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 226c7575c23..843d93973bf 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -95,14 +95,11 @@ bool OSDMonitor::update_from_paxos() dout(15) << "update_from_paxos paxos e " << paxosv << ", my e " << osdmap.epoch << dendl; - if (osdmap.epoch == 0 && paxosv > 0) { - // startup: just load latest full map + if (osdmap.epoch != paxos->get_latest_version()) { bufferlist latest; version_t v = paxos->get_latest(latest); - if (v) { - dout(7) << "update_from_paxos startup: loading latest full map e" << v << dendl; - osdmap.decode(latest); - } + dout(7) << "update_from_paxos loading latest full map e" << v << dendl; + osdmap.decode(latest); } // walk through incrementals diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 5d4fbaf0440..fcf9c64e80a 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -118,23 +118,20 @@ bool PGMonitor::update_from_paxos() return true; assert(paxosv >= pg_map.version); - if (pg_map.version == 0 && paxosv > 0) { - // starting up: load latest + if (pg_map.version != paxos->get_latest_version()) { bufferlist latest; version_t v = paxos->get_latest(latest); - if (v) { - dout(7) << "update_from_paxos startup: got latest latest full pgmap v" << v << dendl; - try { - PGMap tmp_pg_map; - bufferlist::iterator p = latest.begin(); - tmp_pg_map.decode(p); - pg_map = tmp_pg_map; - } - catch (const std::exception &e) { - dout(0) << "update_from_paxos: error parsing update: " - << e.what() << dendl; - return false; - } + dout(7) << "update_from_paxos loading latest full pgmap v" << v << dendl; + try { + PGMap tmp_pg_map; + bufferlist::iterator p = latest.begin(); + tmp_pg_map.decode(p); + pg_map = tmp_pg_map; + } + catch (const std::exception &e) { + dout(0) << "update_from_paxos: error parsing update: " + << e.what() << dendl; + return false; } }