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
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Verify status of ext snapshot dir copy.
Kishore Nallan6096a96385b6
diff --git a/include/raft_server.h b/include/raft_server.hindex 40a09de2..8280338b 100644--- a/include/raft_server.h+++ b/include/raft_server.h@@ -126,6 +126,7 @@ private:std::string raft_dir_path;std::string ext_snapshot_path;+ std::atomic<bool> ext_snapshot_succeeded;int election_timeout_interval_ms;@@ -205,6 +206,8 @@ public:void set_ext_snapshot_path(const std::string &snapshot_path);+ bool get_ext_snapshot_succeeded();+const std::string& get_ext_snapshot_path() const;// for timed snapshotsdiff --git a/src/raft_server.cpp b/src/raft_server.cppindex 6c8228fd..a8432bee 100644--- a/src/raft_server.cpp+++ b/src/raft_server.cpp@@ -429,8 +429,10 @@ void* ReplicationState::save_snapshot(void* arg) {const butil::FilePath& src_snapshot_dir = butil::FilePath(sa->state_dir_path + "/snapshot");const butil::FilePath& src_meta_dir = butil::FilePath(sa->state_dir_path + "/meta");- butil::CopyDirectory(src_snapshot_dir, dest_state_dir, true);- butil::CopyDirectory(src_meta_dir, dest_state_dir, true);+ bool snapshot_copied = butil::CopyDirectory(src_snapshot_dir, dest_state_dir, true);+ bool meta_copied = butil::CopyDirectory(src_meta_dir, dest_state_dir, true);++ sa->replication_state->ext_snapshot_succeeded = snapshot_copied && meta_copied;// notify on demand closure that external snapshotting is donesa->replication_state->notify();@@ -949,6 +951,10 @@ void ReplicationState::do_snapshot(const std::string& nodes) {last_snapshot_ts = current_ts;}+bool ReplicationState::get_ext_snapshot_succeeded() {+ return ext_snapshot_succeeded;+}+void TimedSnapshotClosure::Run() {// Auto delete this after Done()std::unique_ptr<TimedSnapshotClosure> self_guard(this);@@ -973,12 +979,17 @@ void OnDemandSnapshotClosure::Run() {nlohmann::json response;uint32_t status_code;- if(status().ok()) {+ if(status().ok() && replication_state->get_ext_snapshot_succeeded()) {LOG(INFO) << "On demand snapshot succeeded!";status_code = 201;response["success"] = true;} else {- LOG(ERROR) << "On demand snapshot failed, error: " << status().error_str() << ", code: " << status().error_code();+ LOG(ERROR) << "On demand snapshot failed, error: ";+ if(replication_state->get_ext_snapshot_succeeded()) {+ LOG(ERROR) << status().error_str() << ", code: " << status().error_code();+ } else {+ LOG(ERROR) << "Copy failed.";+ }status_code = 500;response["success"] = false;response["error"] = status().error_str();