mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
Fix segfault during shutdown when RAFT server failed to start
This commit is contained in:
parent
4e780cf99f
commit
acd9cb089e
@ -574,7 +574,7 @@ void KeeperDispatcher::shutdown()
|
|||||||
/// Clear all registered sessions
|
/// Clear all registered sessions
|
||||||
std::lock_guard lock(session_to_response_callback_mutex);
|
std::lock_guard lock(session_to_response_callback_mutex);
|
||||||
|
|
||||||
if (hasLeader())
|
if (server && hasLeader())
|
||||||
{
|
{
|
||||||
close_requests.reserve(session_to_response_callback.size());
|
close_requests.reserve(session_to_response_callback.size());
|
||||||
// send to leader CLOSE requests for active sessions
|
// send to leader CLOSE requests for active sessions
|
||||||
@ -598,7 +598,7 @@ void KeeperDispatcher::shutdown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if there is no leader, there is no reason to do CLOSE because it's a write request
|
// 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());
|
LOG_INFO(log, "Trying to close {} session(s)", close_requests.size());
|
||||||
const auto raft_result = server->putRequestBatch(close_requests);
|
const auto raft_result = server->putRequestBatch(close_requests);
|
||||||
|
@ -545,7 +545,7 @@ bool KeeperServer::isFollower() const
|
|||||||
|
|
||||||
bool KeeperServer::isLeaderAlive() 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
|
/// TODO test whether taking failed peer in count
|
||||||
|
Loading…
Reference in New Issue
Block a user