diff --git a/src/kvstore/raftex/Host.cpp b/src/kvstore/raftex/Host.cpp index 22bbad341c4..3a662c30436 100644 --- a/src/kvstore/raftex/Host.cpp +++ b/src/kvstore/raftex/Host.cpp @@ -426,11 +426,12 @@ folly::Future Host::sendHeartbeat( if (t.hasException()) { using TransportException = apache::thrift::transport::TTransportException; auto exWrapper = std::move(t).exception(); + VLOG(2) << self->idStr_ << "Heartbeat: " << exWrapper.what(); auto exception = exWrapper.get_exception(); - VLOG(2) << self->idStr_ << "Heartbeat: " << exception->what(); - // If we keeps receiving NOT_OPEN exception after some HB intervals, + // If we keeps receiving NOT_OPEN and TIMED_OUT exception after some HB intervals, // we can assume that the peer is down so we mark paused_ as true - if (exception && exception->getType() == TransportException::NOT_OPEN) { + if (exception && (exception->getType() == TransportException::NOT_OPEN || + exception->getType() == TransportException::TIMED_OUT)) { if (!self->paused_) { auto now = time::WallClock::fastNowInMilliSec(); if (now - self->lastHeartbeatTime_ >= diff --git a/src/kvstore/raftex/Host.h b/src/kvstore/raftex/Host.h index 49bbf3d9ee8..ca95a1ab1ce 100644 --- a/src/kvstore/raftex/Host.h +++ b/src/kvstore/raftex/Host.h @@ -92,6 +92,7 @@ class Host final : public std::enable_shared_from_this { committedLogId_ = 0; sendingSnapshot_ = false; followerCommittedLogId_ = 0; + lastHeartbeatTime_ = 0; } /**