Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Handle abrupt shutdown better.

kishorenc59c16ddbd9d3
diff --git a/src/raft_server.cpp b/src/raft_server.cpp
index ea709224..989df08b 100644
--- a/src/raft_server.cpp
+++ b/src/raft_server.cpp
@@ -146,7 +146,7 @@ void ReplicationState::write(http_req* request, http_res* response) {
}
void ReplicationState::write_to_leader(http_req *request, http_res *response) const {
- if(node->leader_id().is_empty()) {
+ if(!node || node->leader_id().is_empty()) {
// Handle no leader scenario
LOG(ERROR) << "Rejecting write: could not find a leader.";
@@ -302,11 +302,6 @@ void ReplicationState::on_apply(braft::Iterator& iter) {
delete request;
delete response;
}
-
- if(shut_down) {
- iter.set_error_and_rollback();
- return;
- }
}
}
diff --git a/src/typesense_server_utils.cpp b/src/typesense_server_utils.cpp
index d24be610..fdbe706b 100644
--- a/src/typesense_server_utils.cpp
+++ b/src/typesense_server_utils.cpp
@@ -263,7 +263,7 @@ int start_raft_server(ReplicationState& replication_state, const std::string& st
// Wait until 'CTRL-C' is pressed. then Stop() and Join() the service
size_t raft_counter = 0;
- while (!brpc::IsAskedToQuit() && !quit_raft_service.load()) {
+ while (!quit_raft_service.load()) {
// post-increment to ensure that we refresh right away on a fresh boot
if(raft_counter++ % 10 == 0) {
// reset peer configuration periodically to identify change in cluster membership