Skip to content

Commit

Permalink
mon/MDSMonitor: fix iterating over mutated map
Browse files Browse the repository at this point in the history
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 db3deb8)
  • Loading branch information
John Spray authored and smithfarm committed Jan 26, 2017
1 parent 0591627 commit fef3de8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/mon/MDSMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fef3de8

Please sign in to comment.