]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use realm epoch to choose most recent period to push
authorCasey Bodley <cbodley@redhat.com>
Tue, 8 Dec 2015 16:10:14 +0000 (11:10 -0500)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:51 +0000 (16:13 -0800)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_period_pusher.cc
src/rgw/rgw_period_pusher.h

index e6c87f794be851199ca5a70f9f78816451ed7728..10bf86ec2bfea9cbcd591655ac7742d19efa7438 100644 (file)
@@ -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;
 
index bf3ca1ab1d5e197456c1f3037a30dad7669b8f5f..ccba89783deba3d87b20fc09e179d6c6469841e0 100644 (file)
@@ -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<RGWZonesNeedPeriod> pending_periods;