From ca3b52a375d516a23ca079b36fec9d6fc80a2027 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 11 Mar 2021 18:28:18 +0800 Subject: [PATCH] mon/OSDMonitor: restructure OSDMonitor::check_failures() loop will add a trim failures call in the loop, which mutates failure_info, while we are still iterating this map. so have to restructure the loop a little bit. Fixes: https://tracker.ceph.com/issues/47380 Signed-off-by: Kefu Chai (cherry picked from commit 6e512b2f1e228eb808d6bff1e5c159c4d16667ef) --- src/mon/OSDMonitor.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index dbba6cab33cc5..25189258fb178 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3179,12 +3179,13 @@ bool OSDMonitor::can_mark_in(int i) bool OSDMonitor::check_failures(utime_t now) { bool found_failure = false; - for (map::iterator p = failure_info.begin(); - p != failure_info.end(); - ++p) { - if (can_mark_down(p->first)) { - found_failure |= check_failure(now, p->first, p->second); + auto p = failure_info.begin(); + while (p != failure_info.end()) { + auto& [target_osd, fi] = *p; + if (can_mark_down(target_osd)) { + found_failure |= check_failure(now, target_osd, fi); } + ++p; } return found_failure; } -- 2.39.5