]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson: decouple mgr client reconnect and connect reset handling
authorXuehan Xu <xxhdx1985126@163.com>
Fri, 6 Mar 2020 10:55:07 +0000 (18:55 +0800)
committerXuehan Xu <xxhdx1985126@163.com>
Sat, 7 Mar 2020 03:59:45 +0000 (11:59 +0800)
As of now, the following invocation sequence triggers deadlock when
closing crimson-osd's connection with mgr:
  ProtocolV2::dispatch_reset() --> crimson::mgr::Client::ms_handle_reset
--> crimson::mgr::Client::reconnect --> crimson::net::SocketConnection::close
--> crimson::net::Protocol::close()

In the above invocation sequence, ProtocalV2::dispatch_reset() enters the gate
"pending_dispatch" the leaving of which would wait for the complete of crimson::\
net::Protocal::close() which further wait for the complete of the gate's close().

This commit decouples this waiting chain.

Signed-off-by: Xuehan Xu <xxhdx1985126@163.com>
src/crimson/mgr/client.cc
src/crimson/mgr/client.h

index 9a9c78580c83da98d1a7ce3bcf979ed766fcf131..0cebc1c1e44bbb66e3092d1ada3817543741ed42 100644 (file)
@@ -26,7 +26,7 @@ Client::Client(crimson::net::Messenger& msgr,
                  WithStats& with_stats)
   : msgr{msgr},
     with_stats{with_stats},
-    report_timer{[this] {report();}}
+    tick_timer{[this] {tick();}}
 {}
 
 seastar::future<> Client::start()
@@ -61,10 +61,9 @@ seastar::future<> Client::ms_dispatch(crimson::net::Connection* conn,
 seastar::future<> Client::ms_handle_reset(crimson::net::ConnectionRef c)
 {
   if (conn == c) {
-    return reconnect();
-  } else {
-    return seastar::now();
+    conn = nullptr;
   }
+  return seastar::now();
 }
 
 seastar::future<> Client::reconnect()
@@ -101,22 +100,30 @@ seastar::future<> Client::handle_mgr_conf(crimson::net::Connection* conn,
                                           Ref<MMgrConfigure> m)
 {
   logger().info("{} {}", __func__, *m);
-  report_period = std::chrono::seconds{m->stats_period};
-  if (report_period.count() && !report_timer.armed() ) {
-    report();
+  tick_period = std::chrono::seconds{m->stats_period};
+  if (tick_period.count() && !tick_timer.armed() ) {
+    tick();
   }
   return seastar::now();
 }
 
-void Client::report()
+void Client::tick()
 {
-  (void) seastar::with_gate(gate, [this] {
-    auto pg_stats = with_stats.get_stats();
-    return conn->send(std::move(pg_stats)).finally([this] {
-      if (report_period.count()) {
-        report_timer.arm(report_period);
-      }
-    });
+  (void) seastar::with_gate(gate, [=] {
+    if (conn) {
+      auto pg_stats = with_stats.get_stats();
+      return conn->send(std::move(pg_stats)).finally([this] {
+       if (tick_period.count()) {
+         tick_timer.arm(tick_period);
+       }
+      });
+    } else {
+      return reconnect().finally([this] {
+       if (tick_period.count()) {
+         tick_timer.arm(tick_period);
+       }
+      });;
+    }
   });
 }
 
index fa4ae39df348f68661aa0ae574b6b0d4349b289a..a82b73bc1f81babd45dc26e1b5020911fdea90e4 100644 (file)
@@ -45,15 +45,15 @@ private:
   seastar::future<> handle_mgr_conf(crimson::net::Connection* conn,
                                    Ref<MMgrConfigure> m);
   seastar::future<> reconnect();
-  void report();
+  void tick();
 
 private:
   MgrMap mgrmap;
   crimson::net::Messenger& msgr;
   WithStats& with_stats;
   crimson::net::ConnectionRef conn;
-  std::chrono::seconds report_period{0};
-  seastar::timer<seastar::lowres_clock> report_timer;
+  std::chrono::seconds tick_period{0};
+  seastar::timer<seastar::lowres_clock> tick_timer;
   seastar::gate gate;
 };