]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MgrMonitor: use mono clock to avoid potention issue introduced by time skew 15109/head
authorKefu Chai <kchai@redhat.com>
Tue, 16 May 2017 09:20:11 +0000 (17:20 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 16 May 2017 13:50:56 +0000 (21:50 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/MgrMonitor.cc
src/mon/MgrMonitor.h

index de3c27a245a13f4ab87fa2886b38bd7f9595f256..aa816d4a495a0552131b551734672cca995dfb7b 100644 (file)
@@ -187,7 +187,7 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op)
     }
   }
 
-  last_beacon[m->get_gid()] = ceph_clock_now();
+  last_beacon[m->get_gid()] = ceph::coarse_mono_clock::now();
 
   // Track whether we modified pending_map
   bool updated = false;
@@ -357,9 +357,8 @@ void MgrMonitor::tick()
   if (!is_active() || !mon->is_leader())
     return;
 
-  const utime_t now = ceph_clock_now();
-  utime_t cutoff = now;
-  cutoff -= g_conf->mon_mgr_beacon_grace;
+  const auto now = ceph::coarse_mono_clock::now();
+  const auto cutoff = now - std::chrono::seconds(g_conf->mon_mgr_beacon_grace);
 
   // Populate any missing beacons (i.e. no beacon since MgrMonitor
   // instantiation) with the current time, so that they will
index 280fca5bd1e2eecf6fde3ad67f5bd0a84a8ed221..af3c1aeaffc06b9edd0a53ca37500ec86a909353 100644 (file)
@@ -24,7 +24,7 @@ class MgrMonitor : public PaxosService
 
   utime_t first_seen_inactive;
 
-  std::map<uint64_t, utime_t> last_beacon;
+  std::map<uint64_t, ceph::coarse_mono_clock::time_point> last_beacon;
 
   /**
    * If a standby is available, make it active, given that