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

Fix API server kicking in early before init readiness.

kishorenc901795869d90
diff --git a/include/http_server.h b/include/http_server.h
index e250cd78..1df64b13 100644
--- a/include/http_server.h
+++ b/include/http_server.h
@@ -34,7 +34,7 @@ private:
std::string version;
- std::vector<route_path> routes;
+ std::vector<route_path> routes; // TODO: must be a hashmap?
const std::string listen_address;
diff --git a/src/http_server.cpp b/src/http_server.cpp
index 01855e0d..82cb12d2 100644
--- a/src/http_server.cpp
+++ b/src/http_server.cpp
@@ -217,9 +217,9 @@ int HttpServer::find_route(const std::vector<std::string> & path_parts, const st
bool found = true;
- for(size_t i = 0; i < rpath.path_parts.size(); i++) {
- const std::string & rpart = rpath.path_parts[i];
- const std::string & given_part = path_parts[i];
+ for(size_t j = 0; j < rpath.path_parts.size(); j++) {
+ const std::string & rpart = rpath.path_parts[j];
+ const std::string & given_part = path_parts[j];
if(rpart != given_part && rpart[0] != ':') {
found = false;
break;
diff --git a/src/typesense_server_utils.cpp b/src/typesense_server_utils.cpp
index 0b4a1a99..d8a8280e 100644
--- a/src/typesense_server_utils.cpp
+++ b/src/typesense_server_utils.cpp
@@ -317,7 +317,7 @@ int run_server(const Config & config, const std::string & version,
// Wait for raft service to be ready before starting http
// Follower or leader must have started AND data must also have been loaded
LOG(INFO) << "Waiting for peering service to be ready before starting API service...";
- while(replication_state.get_init_readiness_count() >= 2) {
+ while(replication_state.get_init_readiness_count() < 2) {
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}