]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: MDSMonitor: use pending_mdsmap when selecting items to remove
authorMykola Golub <mgolub@mirantis.com>
Fri, 3 Jul 2015 10:52:40 +0000 (13:52 +0300)
committerMykola Golub <mgolub@mirantis.com>
Tue, 7 Jul 2015 06:07:53 +0000 (09:07 +0300)
This fixes the issue with stale metadata records, observed after mds
restart.

Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/mon/MDSMonitor.cc

index 41b8ef226d90ecc8ad15aeb9fb46e6e908afe7b4..7ff52e17749bf2ab3dd0a338236db2829bad2fdd 100644 (file)
@@ -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<uint64_t>::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<mds_gid_t, Metadata>::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);
 }