From: Kalpesh Pandya Date: Wed, 1 Sep 2021 10:48:33 +0000 (+0530) Subject: src/rgw: AMQP connection timeout X-Git-Tag: v17.1.0~852^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5882c092e9743a29f7625d2befb640d2e9ae646f;p=ceph.git src/rgw: AMQP connection timeout Signed-off-by: Kalpesh Pandya --- diff --git a/src/rgw/rgw_amqp.cc b/src/rgw/rgw_amqp.cc index 9355beaf752..c76d514d86a 100644 --- a/src/rgw/rgw_amqp.cc +++ b/src/rgw/rgw_amqp.cc @@ -131,6 +131,7 @@ struct connection_t { bool use_ssl; bool verify_ssl; boost::optional ca_location; + utime_t timestamp = ceph_clock_now(); // default ctor connection_t() : @@ -583,6 +584,7 @@ public: const size_t max_connections; const size_t max_inflight; const size_t max_queue; + const size_t max_idle_time; private: std::atomic connection_count; std::atomic stopped; @@ -601,6 +603,8 @@ private: const std::unique_ptr msg_owner(message); auto& conn = message->conn; + conn->timestamp = ceph_clock_now(); + if (!conn->is_ok()) { // connection had an issue while message was in the queue // TODO add error stats @@ -697,6 +701,11 @@ private: auto& conn = conn_it->second; const auto& conn_key = conn_it->first; + if(conn->timestamp.sec() + max_idle_time < ceph_clock_now()) { + ldout(conn->cct, 20) << "Time for deleting a connection due to idle behaviour: " << ceph_clock_now() << dendl; + ERASE_AND_CONTINUE(conn_it, connections); + } + // try to reconnect the connection if it has an error if (!conn->is_ok()) { const auto now = ceph::coarse_real_clock::now(); @@ -850,6 +859,7 @@ public: max_connections(_max_connections), max_inflight(_max_inflight), max_queue(_max_queue), + max_idle_time(30), connection_count(0), stopped(false), read_timeout{0, _usec_timeout},