From 1ee26edad534f5010926144c39bc0f81b36fa01a Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 8 Dec 2015 11:10:14 -0500 Subject: [PATCH] rgw: use realm epoch to choose most recent period to push Signed-off-by: Casey Bodley --- src/rgw/rgw_period_pusher.cc | 22 +++++++++++----------- src/rgw/rgw_period_pusher.h | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/rgw/rgw_period_pusher.cc b/src/rgw/rgw_period_pusher.cc index e6c87f794be85..10bf86ec2bfea 100644 --- a/src/rgw/rgw_period_pusher.cc +++ b/src/rgw/rgw_period_pusher.cc @@ -181,7 +181,7 @@ void RGWPeriodPusher::handle_notify(RGWRealmNotify type, try { ::decode(info, p); } catch (buffer::error& e) { - derr << "Failed to decode the period: " << e.what() << dendl; + lderr(cct) << "Failed to decode the period: " << e.what() << dendl; return; } @@ -200,14 +200,14 @@ void RGWPeriodPusher::handle_notify(RGWRealmNotify type, // expects the caller to hold a lock on mutex void RGWPeriodPusher::handle_notify(RGWZonesNeedPeriod&& period) { - if (period.get_id() != period_id) { - // new period must follow current period - if (period.get_predecessor() != period_id) { - ldout(cct, 10) << "current period " << period_id << " is not period " - << period.get_id() << "'s predecessor" << dendl; - return; - } - } else if (period.get_epoch() <= period_epoch) { + if (period.get_realm_epoch() < realm_epoch) { + ldout(cct, 10) << "period's realm epoch " << period.get_realm_epoch() + << " is not newer than current realm epoch " << realm_epoch + << ", discarding update" << dendl; + return; + } + if (period.get_realm_epoch() == realm_epoch && + period.get_epoch() <= period_epoch) { ldout(cct, 10) << "period epoch " << period.get_epoch() << " is not newer " "than current epoch " << period_epoch << ", discarding update" << dendl; return; @@ -267,10 +267,10 @@ void RGWPeriodPusher::handle_notify(RGWZonesNeedPeriod&& period) return; } - period_id = period.get_id(); + realm_epoch = period.get_realm_epoch(); period_epoch = period.get_epoch(); - ldout(cct, 4) << "Zone master pushing period " << period_id + ldout(cct, 4) << "Zone master pushing period " << period.get_id() << " epoch " << period_epoch << " to " << conns.size() << " other zones" << dendl; diff --git a/src/rgw/rgw_period_pusher.h b/src/rgw/rgw_period_pusher.h index bf3ca1ab1d5e1..ccba89783deba 100644 --- a/src/rgw/rgw_period_pusher.h +++ b/src/rgw/rgw_period_pusher.h @@ -43,8 +43,8 @@ class RGWPeriodPusher final : public RGWRealmWatcher::Watcher, RGWRados* store; std::mutex mutex; - std::string period_id; //< the current period id being sent - epoch_t period_epoch; //< the current period epoch being sent + epoch_t realm_epoch{0}; //< the current realm epoch being sent + epoch_t period_epoch{0}; //< the current period epoch being sent /// while paused for reconfiguration, we need to queue up notifications std::vector pending_periods; -- 2.39.5