From 102fbd21aa55c2374751f60844fbcf7cbe2a3af5 Mon Sep 17 00:00:00 2001 From: Mingxin Liu Date: Mon, 19 Mar 2018 18:15:38 +0800 Subject: [PATCH] pg: handle MNotifyRec event in down state if we receive notify with info contains newer les, try getinfo again Signed-off-by: Mingxin Liu --- src/osd/PG.cc | 24 +++++++++++++++++++++++- src/osd/PG.h | 8 +++++--- src/osd/osd_types.cc | 14 ++++++-------- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index e416e336bb696..bcfd2ecdd99cc 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -8379,7 +8379,7 @@ boost::statechart::result PG::RecoveryState::Stray::react(const MInfoRec& infoev pg->info.stats = infoevt.info.stats; pg->info.hit_set = infoevt.info.hit_set; } - + assert(infoevt.info.last_update == pg->info.last_update); assert(pg->pg_log.get_head() == pg->info.last_update); @@ -8902,6 +8902,28 @@ boost::statechart::result PG::RecoveryState::Down::react(const QueryState& q) return forward_event(); } +boost::statechart::result PG::RecoveryState::Down::react(const MNotifyRec& infoevt) +{ + PG *pg = context< RecoveryMachine >().pg; + + assert(pg->is_primary()); + epoch_t old_start = pg->info.history.last_epoch_started; + if (!pg->peer_info.count(infoevt.from) && + pg->get_osdmap()->has_been_up_since(infoevt.from.osd, infoevt.notify.epoch_sent)) { + pg->update_history(infoevt.notify.info.history); + } + // if we got something new to make pg escape down state + if (pg->info.history.last_epoch_started > old_start) { + ldout(pg->cct, 10) << " last_epoch_started moved forward, re-enter getinfo" << dendl; + pg->state_clear(PG_STATE_DOWN); + pg->state_set(PG_STATE_PEERING); + return transit< GetInfo >(); + } + + return discard_event(); +} + + /*------Incomplete--------*/ PG::RecoveryState::Incomplete::Incomplete(my_context ctx) : my_base(ctx), diff --git a/src/osd/PG.h b/src/osd/PG.h index 0575cd8cc9eef..f77a61e122b0d 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -2703,9 +2703,11 @@ protected: struct Down : boost::statechart::state< Down, Peering>, NamedState { explicit Down(my_context ctx); typedef boost::mpl::list < - boost::statechart::custom_reaction< QueryState > + boost::statechart::custom_reaction< QueryState >, + boost::statechart::custom_reaction< MNotifyRec > > reactions; - boost::statechart::result react(const QueryState& infoevt); + boost::statechart::result react(const QueryState& q); + boost::statechart::result react(const MNotifyRec& infoevt); void exit(); }; @@ -2718,7 +2720,7 @@ protected: explicit Incomplete(my_context ctx); boost::statechart::result react(const AdvMap &advmap); boost::statechart::result react(const MNotifyRec& infoevt); - boost::statechart::result react(const QueryState& infoevt); + boost::statechart::result react(const QueryState& q); void exit(); }; diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index ca5ddc0bea3cc..26395415fcce9 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -3492,20 +3492,18 @@ bool PastIntervals::check_new_interval( (*could_have_gone_active)(old_acting_shards)) { if (out) *out << __func__ << " " << i - << ": not rw," << " up_thru " << lastmap->get_up_thru(i.primary) << " up_from " << lastmap->get_up_from(i.primary) - << " last_epoch_clean " << last_epoch_clean - << std::endl; + << " last_epoch_clean " << last_epoch_clean; if (lastmap->get_up_thru(i.primary) >= i.first && lastmap->get_up_from(i.primary) <= i.first) { i.maybe_went_rw = true; if (out) - *out << __func__ << " " << i + *out << " " << i << " : primary up " << lastmap->get_up_from(i.primary) << "-" << lastmap->get_up_thru(i.primary) << " includes interval" - << std::endl; + << std::endl; } else if (last_epoch_clean >= i.first && last_epoch_clean <= i.last) { // If the last_epoch_clean is included in this interval, then @@ -3517,18 +3515,18 @@ bool PastIntervals::check_new_interval( // last_epoch_clean timing. i.maybe_went_rw = true; if (out) - *out << __func__ << " " << i + *out << " " << i << " : includes last_epoch_clean " << last_epoch_clean << " and presumed to have been rw" << std::endl; } else { i.maybe_went_rw = false; if (out) - *out << __func__ << " " << i + *out << " " << i << " : primary up " << lastmap->get_up_from(i.primary) << "-" << lastmap->get_up_thru(i.primary) << " does not include interval" - << std::endl; + << std::endl; } } else { i.maybe_went_rw = false; -- 2.39.5