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

Sort queued requests by timestamp before restore.

Kishore Nalland9b969aab5a5
diff --git a/src/batched_indexer.cpp b/src/batched_indexer.cpp
index e149487e..04e5d1e1 100644
--- a/src/batched_indexer.cpp
+++ b/src/batched_indexer.cpp
@@ -385,16 +385,16 @@ void BatchedIndexer::load_state(const nlohmann::json& state) {
queue_ids.push_back(queue_id);
std::unique_lock qlk(qmutuxes[queue_id].mcv);
queues[queue_id].emplace_back(req->start_ts);
- qmutuxes[queue_id].cv.notify_one();
}
num_reqs_restored++;
}
- // need to sort on `start_ts` to preserve original order
+ // need to sort on `start_ts` to preserve original order before notifying queues
for(auto queue_id: queue_ids) {
std::unique_lock lk(qmutuxes[queue_id].mcv);
std::sort(queues[queue_id].begin(), queues[queue_id].end());
+ qmutuxes[queue_id].cv.notify_one();
}
LOG(INFO) << "Restored " << num_reqs_restored << " in-flight requests from snapshot.";