From: Sage Weil Date: Tue, 6 Oct 2015 19:11:03 +0000 (-0400) Subject: mon: new session_timeout mechanism that is not subscribe-based X-Git-Tag: v10.0.1~26^2~31 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e5fc790329e5209acd5218bf78ab3aa704f8a1e0;p=ceph.git mon: new session_timeout mechanism that is not subscribe-based Simplify the session liveness detection: - renew on any message - renew on keepalive[2] messages (lightweight ping in msgr) Signed-off-by: Sage Weil --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 388e982148f..f8c9b0d7928 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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 diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 2aab566c034..64cbb6cc62f 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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 diff --git a/src/mon/Session.h b/src/mon/Session.h index ff807302790..e8b187e2ba3 100644 --- a/src/mon/Session.h +++ b/src/mon/Session.h @@ -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;