From: luo rixin Date: Tue, 12 Nov 2019 08:36:53 +0000 (+0800) Subject: mon/PGMap: fix incorrect pg_pool_sum when delete pool X-Git-Tag: v15.1.0~878^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=446eca8defddda44fea7c789065afdb1a9d38dae;p=ceph.git 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 --- diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index ee4334f2ac3..e1ce677436c 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();