diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 3aeb7962682..938e2862aaa 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -309,8 +309,11 @@ void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s) pg_sum.sub(s); if (s.state & PG_STATE_CREATING) { creating_pgs.erase(pgid); - if (s.acting.size()) + if (s.acting.size()) { creating_pgs_by_osd[s.acting[0]].erase(pgid); + if (creating_pgs_by_osd[s.acting[0]].size() == 0) + creating_pgs_by_osd.erase(s.acting[0]); + } } } diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 6a6dd60b84b..b66ae895225 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -775,8 +775,11 @@ void PGMonitor::send_pg_creates() vector acting; int nrep = mon->osdmon()->osdmap.pg_to_acting_osds(on, acting); - if (s.acting.size()) + if (s.acting.size()) { pg_map.creating_pgs_by_osd[s.acting[0]].erase(pgid); + if (pg_map.creating_pgs_by_osd[s.acting[0]].size() == 0) + pg_map.creating_pgs_by_osd.erase(s.acting[0]); + } s.acting = acting; // don't send creates for localized pgs @@ -812,6 +815,7 @@ void PGMonitor::send_pg_creates(int osd, Connection *con) map >::iterator p = pg_map.creating_pgs_by_osd.find(osd); if (p == pg_map.creating_pgs_by_osd.end()) return; + assert(p->second.size() > 0); dout(20) << "send_pg_creates osd." << osd << " pgs " << p->second << dendl; MOSDPGCreate *m = new MOSDPGCreate(mon->osdmon()->osdmap.get_epoch());