From df46ea28f9aa7801c0de674058f1380e6b29ea81 Mon Sep 17 00:00:00 2001 From: Kishore Nallan Date: Sat, 2 Jul 2022 18:08:24 +0530 Subject: [PATCH] Fix status endpoint response during snapshot loading. --- src/raft_server.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/raft_server.cpp b/src/raft_server.cpp index 327c1fca..3df93670 100644 --- a/src/raft_server.cpp +++ b/src/raft_server.cpp @@ -128,6 +128,7 @@ int ReplicationState::start(const butil::EndPoint & peering_endpoint, const int LOG(INFO) << "Node last_index: " << node_status.last_index; + std::unique_lock lock(node_mutex); this->node = node; return 0; } @@ -826,6 +827,10 @@ nlohmann::json ReplicationState::get_status() { std::shared_lock lock(node_mutex); if(!node) { + // `node` is not yet initialized (probably loading snapshot) + status["state"] = "NOT_READY"; + status["committed_index"] = 0; + status["queued_writes"] = 0; return status; }