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

Use separate threadpool for replication state.

Kishore Nallanf038e998090c
diff --git a/src/typesense_server_utils.cpp b/src/typesense_server_utils.cpp
index 64b945fa..674e1acb 100644
--- a/src/typesense_server_utils.cpp
+++ b/src/typesense_server_utils.cpp
@@ -409,6 +409,7 @@ int run_server(const Config & config, const std::string & version, void (*master
LOG(INFO) << "Thread pool size: " << num_threads;
ThreadPool app_thread_pool(num_threads);
ThreadPool server_thread_pool(num_threads);
+ ThreadPool replication_thread_pool(num_threads);
// primary DB used for storing the documents: we will not use WAL since Raft provides that
Store store(db_dir);
@@ -457,14 +458,14 @@ int run_server(const Config & config, const std::string & version, void (*master
// first we start the peering service
ReplicationState replication_state(server, batch_indexer, &store,
- &app_thread_pool, server->get_message_dispatcher(),
+ &replication_thread_pool, server->get_message_dispatcher(),
ssl_enabled,
&config,
num_collections_parallel_load,
config.get_num_documents_parallel_load());
std::thread raft_thread([&replication_state, &config, &state_dir,
- &app_thread_pool, &server_thread_pool, batch_indexer]() {
+ &app_thread_pool, &server_thread_pool, &replication_thread_pool, batch_indexer]() {
std::thread batch_indexing_thread([batch_indexer]() {
batch_indexer->run();
@@ -493,6 +494,10 @@ int run_server(const Config & config, const std::string & version, void (*master
app_thread_pool.shutdown();
+ LOG(INFO) << "Shutting down replication_thread_pool.";
+
+ replication_thread_pool.shutdown();
+
server->stop();
});