]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: new session_timeout mechanism that is not subscribe-based
authorSage Weil <sage@redhat.com>
Tue, 6 Oct 2015 19:11:03 +0000 (15:11 -0400)
committerSage Weil <sage@redhat.com>
Mon, 23 Nov 2015 13:38:48 +0000 (08:38 -0500)
Simplify the session liveness detection:

 - renew on any message
 - renew on keepalive[2] messages (lightweight ping in msgr)

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/mon/Monitor.cc
src/mon/Session.h

index 388e982148fd04b4c605d03a605b800ff7dbe17a..f8c9b0d7928a17d275d76f7d99188addb0e4b617 100644 (file)
@@ -194,6 +194,7 @@ OPTION(mon_compact_on_trim, OPT_BOOL, true)       // compact (a prefix) when we
 OPTION(mon_osd_cache_size, OPT_INT, 10)  // the size of osdmaps cache, not to rely on underlying store's cache
 
 OPTION(mon_tick_interval, OPT_INT, 5)
+OPTION(mon_session_timeout, OPT_INT, 300)    // must send keepalive or subscribe
 OPTION(mon_subscribe_interval, OPT_DOUBLE, 300)
 OPTION(mon_delta_reset_interval, OPT_DOUBLE, 10)   // seconds of inactivity before we reset the pg delta to 0
 OPTION(mon_osd_laggy_halflife, OPT_INT, 60*60)        // (seconds) how quickly our laggy estimations decay
index 2aab566c0341b536ce4dbe08c055e210002d4b86..64cbb6cc62f59f57e4c1bfd4c0410bc980a48d73 100644 (file)
@@ -3455,6 +3455,10 @@ void Monitor::_ms_dispatch(Message *m)
   }
 
   assert(s);
+
+  s->session_timeout = ceph_clock_now(NULL);
+  s->session_timeout += g_conf->mon_session_timeout;
+
   if (s->auth_handler) {
     s->entity_name = s->auth_handler->get_entity_name();
   }
@@ -4698,11 +4702,17 @@ void Monitor::tick()
     
     // don't trim monitors
     if (s->inst.name.is_mon())
-      continue; 
+      continue;
 
-    if (!s->until.is_zero() && s->until < now) {
+    if (s->session_timeout < now && s->con) {
+      // check keepalive, too
+      s->session_timeout = s->con->get_last_keepalive();
+      s->session_timeout += g_conf->mon_session_timeout;
+    }
+    if (s->session_timeout < now) {
       dout(10) << " trimming session " << s->con << " " << s->inst
-              << " (until " << s->until << " < now " << now << ")" << dendl;
+              << " (timeout " << s->session_timeout
+              << " < now " << now << ")" << dendl;
     } else if (out_for_too_long) {
       // boot the client Session because we've taken too long getting back in
       dout(10) << " trimming session " << s->con << " " << s->inst
index ff8073027908bcfa23c763e9f66ccc92664fe364..e8b187e2ba33e2ffa4dbcbde6418daa92efc6db0 100644 (file)
@@ -40,6 +40,7 @@ struct Subscription {
 struct MonSession : public RefCountedObject {
   ConnectionRef con;
   entity_inst_t inst;
+  utime_t session_timeout;
   utime_t until;
   utime_t time_established;
   bool closed;