Skip to content

Commit

Permalink
mon/OSDMonitor: ignore and/or remove pgs that shouldn't exist
Browse files Browse the repository at this point in the history
The update_creating_pgs() change is there mainly for clusters that already
have an invalid pg in the map; going forward they hopefully shouldn't
appear!

Fixes: https://tracker.ceph.com/issues/22847
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit cd013ed)

Conflicts:
	src/mon/OSDMonitor.cc (luminous does not have d0a477b)
  • Loading branch information
liewegas authored and smithfarm committed Feb 12, 2018
1 parent 5f8c196 commit 88595d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
24 changes: 22 additions & 2 deletions src/mon/OSDMonitor.cc
Expand Up @@ -684,7 +684,8 @@ void OSDMonitor::create_pending()
}

creating_pgs_t
OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc)
OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc,
const OSDMap& nextmap)
{
dout(10) << __func__ << dendl;
creating_pgs_t pending_creatings;
Expand Down Expand Up @@ -735,6 +736,20 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc)
pending_creatings.last_scan_epoch = osdmap.get_epoch();
}

// filter out any pgs that shouldn't exist.
{
auto i = pending_creatings.pgs.begin();
while (i != pending_creatings.pgs.end()) {
if (!nextmap.pg_exists(i->first)) {
dout(10) << __func__ << " removing pg " << i->first
<< " which should not exist" << dendl;
i = pending_creatings.pgs.erase(i);
} else {
++i;
}
}
}

// process queue
unsigned max = MAX(1, g_conf->mon_osd_max_creating_pgs);
const auto total = pending_creatings.pgs.size();
Expand Down Expand Up @@ -1373,7 +1388,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t)
// and pg creating, also!
if (mon->monmap->get_required_features().contains_all(
ceph::features::mon::FEATURE_LUMINOUS)) {
auto pending_creatings = update_pending_pgs(pending_inc);
auto pending_creatings = update_pending_pgs(pending_inc, tmp);
if (osdmap.get_epoch() &&
osdmap.require_osd_release < CEPH_RELEASE_LUMINOUS) {
dout(7) << __func__ << " in the middle of upgrading, "
Expand Down Expand Up @@ -3407,6 +3422,11 @@ void OSDMonitor::update_creating_pgs()
for (const auto& pg : creating_pgs.pgs) {
int acting_primary = -1;
auto pgid = pg.first;
if (!osdmap.pg_exists(pgid)) {
dout(20) << __func__ << " ignoring " << pgid << " which should not exist"
<< dendl;
continue;
}
auto mapped = pg.second.first;
dout(20) << __func__ << " looking up " << pgid << "@" << mapped << dendl;
mapping.get(pgid, nullptr, nullptr, nullptr, &acting_primary);
Expand Down
3 changes: 2 additions & 1 deletion src/mon/OSDMonitor.h
Expand Up @@ -453,7 +453,8 @@ class OSDMonitor : public PaxosService {
creating_pgs_t creating_pgs;
mutable std::mutex creating_pgs_lock;

creating_pgs_t update_pending_pgs(const OSDMap::Incremental& inc);
creating_pgs_t update_pending_pgs(const OSDMap::Incremental& inc,
const OSDMap& nextmap);
void trim_creating_pgs(creating_pgs_t *creating_pgs,
const ceph::unordered_map<pg_t,pg_stat_t>& pgm);
unsigned scan_for_creating_pgs(
Expand Down

0 comments on commit 88595d1

Please sign in to comment.