diff --git a/src/Coordination/KeeperDispatcher.cpp b/src/Coordination/KeeperDispatcher.cpp index 261e43d80e4..d725ecb5cfe 100644 --- a/src/Coordination/KeeperDispatcher.cpp +++ b/src/Coordination/KeeperDispatcher.cpp @@ -370,7 +370,7 @@ void KeeperDispatcher::shutdown() /// Clear all registered sessions std::lock_guard lock(session_to_response_callback_mutex); - if (hasLeader()) + if (server && hasLeader()) { close_requests.reserve(session_to_response_callback.size()); // send to leader CLOSE requests for active sessions @@ -394,7 +394,7 @@ void KeeperDispatcher::shutdown() } // if there is no leader, there is no reason to do CLOSE because it's a write request - if (hasLeader() && !close_requests.empty()) + if (server && hasLeader() && !close_requests.empty()) { LOG_INFO(log, "Trying to close {} session(s)", close_requests.size()); const auto raft_result = server->putRequestBatch(close_requests); diff --git a/src/Coordination/KeeperServer.cpp b/src/Coordination/KeeperServer.cpp index 8186ddd0c00..42d7d967b1f 100644 --- a/src/Coordination/KeeperServer.cpp +++ b/src/Coordination/KeeperServer.cpp @@ -520,7 +520,7 @@ bool KeeperServer::isFollower() const bool KeeperServer::isLeaderAlive() const { - return raft_instance->is_leader_alive(); + return raft_instance && raft_instance->is_leader_alive(); } /// TODO test whether taking failed peer in count