From: Mykola Golub Date: Fri, 3 Jul 2015 10:52:40 +0000 (+0300) Subject: mon: MDSMonitor: use pending_mdsmap when selecting items to remove X-Git-Tag: v9.0.3~26^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c5a09a6bd1642f96ce3850f0ac6742bb293944a1;p=ceph.git mon: MDSMonitor: use pending_mdsmap when selecting items to remove This fixes the issue with stale metadata records, observed after mds restart. Signed-off-by: Mykola Golub --- diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 41b8ef226d90..7ff52e17749b 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -175,8 +175,8 @@ void MDSMonitor::encode_pending(MonitorDBStore::TransactionRef t) i != pending_daemon_health_rm.end(); ++i) { t->erase(MDS_HEALTH_PREFIX, stringify(*i)); } - remove_from_metadata(t); pending_daemon_health_rm.clear(); + remove_from_metadata(t); } version_t MDSMonitor::get_trim_to() @@ -1785,13 +1785,18 @@ void MDSMonitor::remove_from_metadata(MonitorDBStore::TransactionRef t) ::decode(last_metadata, iter); bl.clear(); - if (pending_daemon_health_rm.empty()) { - return; - } - for (std::set::const_iterator to_remove = pending_daemon_health_rm.begin(); - to_remove != pending_daemon_health_rm.end(); ++to_remove) { - last_metadata.erase(mds_gid_t(*to_remove)); + bool update = false; + for (map::iterator i = last_metadata.begin(); + i != last_metadata.end(); ) { + if (pending_mdsmap.get_state_gid(i->first) == MDSMap::STATE_NULL) { + last_metadata.erase(i++); + update = true; + } else { + ++i; + } } + if (!update) + return; ::encode(last_metadata, bl); t->put(MDS_METADATA_PREFIX, "last_metadata", bl); }