]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MDSMonitor: fix iterating over mutated map 13123/head
authorJohn Spray <john.spray@redhat.com>
Thu, 8 Dec 2016 16:49:04 +0000 (16:49 +0000)
committerNathan Cutler <ncutler@suse.com>
Thu, 26 Jan 2017 09:02:38 +0000 (10:02 +0100)
If a standby is promoted, this was modifying the
standby_daemons map that we were iterating over
in maybe_promote_standby.

Fixes: http://tracker.ceph.com/issues/18166
Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit db3deb80d6e4a8e8ca7a2cf6278d5d5cb24eb616)

src/mon/MDSMonitor.cc

index d5260ebe8f4620dd15decfcaa169b706035319d2..945cefd460584cd68d99dd4103948dbc677b0c5f 100644 (file)
@@ -2789,9 +2789,17 @@ bool MDSMonitor::maybe_promote_standby(std::shared_ptr<Filesystem> fs)
   } else {
     // There were no failures to replace, so try using any available standbys
     // as standby-replay daemons.
+
+    // Take a copy of the standby GIDs so that we can iterate over
+    // them while perhaps-modifying standby_daemons during the loop
+    // (if we promote anyone they are removed from standby_daemons)
+    std::vector<mds_gid_t> standby_gids;
     for (const auto &j : pending_fsmap.standby_daemons) {
-      const auto &gid = j.first;
-      const auto &info = j.second;
+      standby_gids.push_back(j.first);
+    }
+
+    for (const auto &gid : standby_gids) {
+      const auto &info = pending_fsmap.standby_daemons.at(gid);
       assert(info.state == MDSMap::STATE_STANDBY);
 
       if (!info.standby_replay) {