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

Improve logging for replication errors.

kishorenccf26a1690348
diff --git a/include/store.h b/include/store.h
index 55d81a10..e805e2b4 100644
--- a/include/store.h
+++ b/include/store.h
@@ -171,8 +171,12 @@ public:
if(!status.ok()) {
LOG(ERR) << "Error while fetching updates for replication: " << status.ToString();
+
std::ostringstream error;
- error << "Unable to fetch updates. " << "Master's latest sequence number is " << local_latest_seq_num;
+ error << "Unable to fetch updates. " << "Master's latest sequence number is " << local_latest_seq_num
+ << " but requested sequence number is " << seq_number;
+ LOG(ERR) << error.str();
+
return Option<std::vector<std::string>*>(400, error.str());
}
@@ -181,6 +185,7 @@ public:
error << "Invalid iterator. Master's latest sequence number is " << local_latest_seq_num << " but "
<< "updates are requested from sequence number " << seq_number << ". "
<< "The master's WAL entries might have expired (they are kept only for 24 hours).";
+ LOG(ERR) << error.str();
return Option<std::vector<std::string>*>(400, error.str());
}
@@ -198,6 +203,7 @@ public:
error << "Invalid iterator. Requested sequence number is " << seq_number << " but "
<< "updates are available only from sequence number " << batch.sequence << ". "
<< "The master's WAL entries might have expired (they are kept only for 24 hours).";
+ LOG(ERR) << error.str();
return Option<std::vector<std::string>*>(400, error.str());
}
}
diff --git a/test/store_test.cpp b/test/store_test.cpp
index 9dbb7528..6206832e 100644
--- a/test/store_test.cpp
+++ b/test/store_test.cpp
@@ -29,7 +29,8 @@ TEST(StoreTest, GetUpdatesSince) {
// querying for a seq_num > 1 on a fresh store
updates_op = primary_store.get_updates_since(2, 10);
ASSERT_FALSE(updates_op.ok());
- ASSERT_EQ("Unable to fetch updates. Master's latest sequence number is 0", updates_op.error());
+ ASSERT_EQ("Unable to fetch updates. Master's latest sequence number is 0 but "
+ "requested sequence number is 2", updates_op.error());
// get_updates_since(1) == get_updates_since(0) even after inserting a record
primary_store.insert("foo1", "bar1");
@@ -112,7 +113,8 @@ TEST(StoreTest, GetUpdatesSince) {
updates_op = primary_store.get_updates_since(50, 100);
ASSERT_FALSE(updates_op.ok());
- ASSERT_EQ("Unable to fetch updates. Master's latest sequence number is 3", updates_op.error());
+ ASSERT_EQ("Unable to fetch updates. Master's latest sequence number is 3 but "
+ "requested sequence number is 50", updates_op.error());
}
TEST(StoreTest, GetUpdateSinceInvalidIterator) {