]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: handle fault for READY, CONNECTING and ACCEPTING
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 8 Aug 2019 09:03:39 +0000 (17:03 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Mon, 12 Aug 2019 09:22:45 +0000 (17:22 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/net/ProtocolV2.cc
src/crimson/net/ProtocolV2.h

index 9474562e1387ca2361b6964be78d1888e04f8638..892f6a2afbdd33b72e2b55b08ce2699dcf2b7764 100644 (file)
@@ -403,15 +403,18 @@ void ProtocolV2::trigger_state(state_t _state, write_state_t _write_state, bool
   set_write_state(_write_state);
 }
 
-seastar::future<> ProtocolV2::fault()
+void ProtocolV2::fault(bool backoff)
 {
-  logger().warn("{} fault during {}",
-                conn, get_state_name(state));
-  // TODO: <fault logic here: e.g. backoff, policies, etc.>
-  // TODO: <conditions to call execute_standby()>
-  // TODO: <conditions to call execute_connecting()>
-  close();
-  return seastar::now();
+  if (conn.policy.lossy) {
+    dispatch_reset();
+    close();
+  } else if (conn.policy.server || (conn.policy.standby && !is_queued())) {
+    execute_standby();
+  } else if (backoff) {
+    execute_wait(false);
+  } else {
+    execute_connecting();
+  }
 }
 
 void ProtocolV2::dispatch_reset()
@@ -955,8 +958,20 @@ void ProtocolV2::execute_connecting()
            }
           }
         }).handle_exception([this] (std::exception_ptr eptr) {
-          // TODO: handle fault in CONNECTING state
-          return fault();
+          logger().debug("{} execute_connecting(): got exception {} at state {}",
+                         conn, eptr, get_state_name(state));
+          if (state != state_t::CONNECTING) {
+            assert(state == state_t::CLOSING ||
+                   state == state_t::REPLACING);
+            logger().debug("{} execute_connecting() protocol aborted", conn);
+            return;
+          }
+
+          if (conn.policy.server || (conn.policy.standby && !is_queued())) {
+            execute_standby();
+          } else {
+            execute_wait(false);
+          }
         });
     });
 }
@@ -1439,8 +1454,9 @@ void ProtocolV2::execute_accepting()
            }
           }
         }).handle_exception([this] (std::exception_ptr eptr) {
-          // TODO: handle fault in ACCEPTING state
-          return fault();
+          logger().warn("{} execute_accepting(): got exception {} at state {}",
+                        conn, eptr, get_state_name(state));
+          close();
         });
     });
 }
@@ -1765,8 +1781,15 @@ void ProtocolV2::execute_ready()
         }
       });
     }).handle_exception([this] (std::exception_ptr eptr) {
-      // TODO: handle fault in READY state
-      return fault();
+      logger().debug("{} execute_ready(): got exception {} at state {}",
+                     conn, eptr, get_state_name(state));
+      if (state != state_t::READY) {
+        assert(state == state_t::REPLACING ||
+               state == state_t::CLOSING);
+        logger().debug("{} execute_ready() protocol aborted", conn);
+        return;
+      }
+      fault(false);
     });
   });
 }
index 179299f7298d9ca8cbbc88eef3869e471369c8a5..b8e97ba80bfdbdfbc9109c4bd5c9b342fd0f374b 100644 (file)
@@ -121,7 +121,7 @@ class ProtocolV2 final : public Protocol {
   seastar::future<> write_frame(F &frame, bool flush=true);
 
  private:
-  seastar::future<> fault();
+  void fault(bool backoff);
   void dispatch_reset();
   void reset_session(bool full);
   seastar::future<entity_type_t, entity_addr_t> banner_exchange();