]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: fix unexpected connection markdown in heartbeat
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 27 Aug 2020 02:29:11 +0000 (10:29 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Thu, 27 Aug 2020 03:05:09 +0000 (11:05 +0800)
Pass reference when log Heartbeat::Connection instance, or the
destructor will be called incorrectly, and the conn be marked down
unexpectedly.

Also, the replacing conn is actually connected during replacement-reset
event.

Fixes: https://tracker.ceph.com/issues/47124
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/net/ProtocolV2.cc
src/crimson/osd/heartbeat.cc
src/crimson/osd/heartbeat.h

index 3e348241569b8983c7e1ef5eca7e3142c30385d5..fd9567be9949e542d80723f6fa7d910829ec19d1 100644 (file)
@@ -1591,6 +1591,12 @@ void ProtocolV2::execute_establishing(
   trigger_state(state_t::ESTABLISHING, write_state_t::delay, false);
   if (existing_conn) {
     existing_conn->protocol->close(dispatch_reset, std::move(accept_me));
+    if (unlikely(state != state_t::ESTABLISHING)) {
+      logger().warn("{} triggered {} during execute_establishing(), "
+                    "the accept event will not be delivered!",
+                    conn, get_state_name(state));
+      abort_protocol();
+    }
   } else {
     accept_me();
   }
index bd7f906f322e1a38247bc9f5a7af96f43f8e678d..d8dc1e550e168cfce2f938d359d9488c88325225 100644 (file)
@@ -402,7 +402,7 @@ void Heartbeat::Connection::replaced()
   racing_detected = true;
   logger().warn("Heartbeat::Connection::replaced(): {} racing", *this);
   assert(conn != replaced_conn);
-  assert(!conn->is_connected());
+  assert(conn->is_connected());
 }
 
 void Heartbeat::Connection::reset()
index d71d4e0c87c2c70b6afa976f9ac3e6c905b79358..b8d13ee356712bade9d27914c5a7d90ef063ba4b 100644 (file)
@@ -176,6 +176,11 @@ class Heartbeat::Connection {
       is_winner_side{is_winner_side} {
     connect();
   }
+  Connection(const Connection&) = delete;
+  Connection(Connection&&) = delete;
+  Connection& operator=(const Connection&) = delete;
+  Connection& operator=(Connection&&) = delete;
+
   ~Connection();
 
   bool matches(crimson::net::Connection* _conn) const;
@@ -235,7 +240,7 @@ class Heartbeat::Connection {
   crimson::net::ConnectionRef conn;
   bool is_connected = false;
 
- friend std::ostream& operator<<(std::ostream& os, const Connection c) {
+ friend std::ostream& operator<<(std::ostream& os, const Connection& c) {
    if (c.type == type_t::front) {
      return os << "con_front(osd." << c.peer << ")";
    } else {
@@ -393,6 +398,7 @@ class Heartbeat::Peer final : private Heartbeat::ConnectionListener {
   ~Peer();
   Peer(Peer&&) = delete;
   Peer(const Peer&) = delete;
+  Peer& operator=(Peer&&) = delete;
   Peer& operator=(const Peer&) = delete;
 
   void set_epoch(epoch_t epoch) { session.set_epoch(epoch); }