From c19326cef28ca3764340434cacc1f77e5899b887 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 3 Oct 2016 07:33:27 +0100 Subject: [PATCH] mon: don't crash on invalid standby_for_fscid Fixes: http://tracker.ceph.com/issues/17466 Signed-off-by: John Spray (cherry picked from commit 92fdcf36bd7d57b97f5d887d0370a181860e388c) --- src/mon/MDSMonitor.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 6d6fb9d52d336..baf59e2260daf 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -2815,6 +2815,17 @@ bool MDSMonitor::maybe_promote_standby(std::shared_ptr fs) pending_fsmap.legacy_client_fscid : info.standby_for_fscid, info.standby_for_rank}; + // It is possible that the map contains a standby_for_fscid + // that doesn't correspond to an existing filesystem, especially + // if we loaded from a version with a bug (#17466) + if (info.standby_for_fscid != FS_CLUSTER_ID_NONE + && pending_fsmap.get_filesystems().count( + info.standby_for_fscid) == 0) { + derr << "gid " << gid << " has invalid standby_for_fscid " + << info.standby_for_fscid << dendl; + continue; + } + // If we managed to resolve a full target role if (target_role.fscid != FS_CLUSTER_ID_NONE) { auto fs = pending_fsmap.get_filesystem(target_role.fscid); -- 2.39.5