]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add clock sync backoff to handle_lease_ack
authorGreg Farnum <gregf@hq.newdream.net>
Tue, 24 Aug 2010 18:54:49 +0000 (11:54 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Tue, 24 Aug 2010 18:54:49 +0000 (11:54 -0700)
src/mon/Paxos.cc

index cb7c104e5d2e44de43eadf7e0a623480dee6f4f4..cc69acca0400bcea975dd37b873bf4260ff6fb35 100644 (file)
@@ -574,9 +574,8 @@ void Paxos::handle_lease(MMonPaxos *lease)
   allowed_time.set_from_double(g_clock.now() + g_conf.mon_clock_drift_allowed);
   if (lease->sent_timestamp > allowed_time) {
     utime_t warn_diff = g_clock.now() - last_clock_drift_warn;
-    if ((last_clock_drift_warn == utime_t()) ||
-       (warn_diff >
-        pow(g_conf.mon_clock_drift_warn_backoff, clock_drift_warned))) {
+    if (warn_diff >
+        pow(g_conf.mon_clock_drift_warn_backoff, clock_drift_warned)) {
       stringstream ss;
       ss << "lease_expire from mon" << lease->get_source().num()
         << " was sent from future time " << lease->sent_timestamp
@@ -653,12 +652,18 @@ void Paxos::handle_lease_ack(MMonPaxos *ack)
   utime_t allowed_time;
   allowed_time.set_from_double(g_clock.now() + g_conf.mon_clock_drift_allowed);
   if (ack->sent_timestamp > allowed_time) {
-    stringstream ss;
-    ss << "lease_ack from mon" << from
-       << " was sent from future time " << ack->sent_timestamp
-       << " with allowed time <=" << allowed_time
-       << ", clocks not synchronized." << std::endl;
-    mon->get_logclient()->log(LOG_WARN, ss);
+    utime_t warn_diff = g_clock.now() - last_clock_drift_warn;
+    if (warn_diff >
+         pow(g_conf.mon_clock_drift_warn_backoff, clock_drift_warned)) {
+      stringstream ss;
+      ss << "lease_ack from mon" << from
+          << " was sent from future time " << ack->sent_timestamp
+          << " with allowed time <=" << allowed_time
+          << ", clocks not synchronized." << std::endl;
+      mon->get_logclient()->log(LOG_WARN, ss);
+      last_clock_drift_warn = g_clock.now();
+      ++clock_drift_warned;
+    }
   }
   ack->put();
 }