From 446eca8defddda44fea7c789065afdb1a9d38dae Mon Sep 17 00:00:00 2001 From: luo rixin Date: Tue, 12 Nov 2019 16:36:53 +0800 Subject: [PATCH] mon/PGMap: fix incorrect pg_pool_sum when delete pool We found the pools num diplayed by "ceph -s" is not the same with "ceph osd lspools" after deleting a pool sometime. The result is Mgr ClusterState::ingest_pgstats get the old pg_stat which pg is not deleted in some osd before the pool deleted and add to pending_inc.pool_statfs_updates. The deleted pool will be added to pg_pool_sum unconsciously by PGMap::apply_incremental and which has been deleted in OSDMap. This will also casue MON's Segmentation fault. Fixes: https://tracker.ceph.com/issues/42689 Fixes: https://tracker.ceph.com/issues/42592 Fixes: https://tracker.ceph.com/issues/41228 Fixes: https://tracker.ceph.com/issues/40011 Signed-off-by: luo rixin --- src/mon/PGMap.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index ee4334f2ac39a..e1ce677436cfe 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -1175,14 +1175,16 @@ void PGMap::apply_incremental(CephContext *cct, const Incremental& inc) auto pool_statfs_iter = pool_statfs.find(std::make_pair(update_pool, update_osd)); - pool_stat_t &pool_sum_ref = pg_pool_sum[update_pool]; - if (pool_statfs_iter == pool_statfs.end()) { - pool_statfs.emplace(std::make_pair(update_pool, update_osd), statfs_inc); - } else { - pool_sum_ref.sub(pool_statfs_iter->second); - pool_statfs_iter->second = statfs_inc; + if (pg_pool_sum.count(update_pool)) { + pool_stat_t &pool_sum_ref = pg_pool_sum[update_pool]; + if (pool_statfs_iter == pool_statfs.end()) { + pool_statfs.emplace(std::make_pair(update_pool, update_osd), statfs_inc); + } else { + pool_sum_ref.sub(pool_statfs_iter->second); + pool_statfs_iter->second = statfs_inc; + } + pool_sum_ref.add(statfs_inc); } - pool_sum_ref.add(statfs_inc); } for (auto p = inc.get_osd_stat_updates().begin(); -- 2.39.5