From d4751e34c406358ae8ea1d5163068740b9403757 Mon Sep 17 00:00:00 2001 From: yawzhang Date: Thu, 28 Nov 2024 17:03:53 +0800 Subject: [PATCH] fix create_snapshot --- conanfile.py | 2 +- .../homestore_backend/replication_state_machine.cpp | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/conanfile.py b/conanfile.py index 2988441..59fedf6 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ class HomeObjectConan(ConanFile): name = "homeobject" - version = "2.1.11" + version = "2.1.12" homepage = "https://github.com/eBay/HomeObject" description = "Blob Store built on HomeReplication" diff --git a/src/lib/homestore_backend/replication_state_machine.cpp b/src/lib/homestore_backend/replication_state_machine.cpp index 2b8d5f5..2d4ca50 100644 --- a/src/lib/homestore_backend/replication_state_machine.cpp +++ b/src/lib/homestore_backend/replication_state_machine.cpp @@ -201,11 +201,13 @@ ReplicationStateMachine::create_snapshot(std::shared_ptr< homestore::snapshot_co auto s = ctx->nuraft_snapshot(); std::lock_guard lk(m_snapshot_lock); - auto current = dynamic_pointer_cast< homestore::nuraft_snapshot_context >(m_snapshot_context)->nuraft_snapshot(); - if (s->get_last_log_idx() < current->get_last_log_idx()) { - LOGI("Skipping create snapshot new idx/term: {}/{} current idx/term: {}/{}", s->get_last_log_idx(), - s->get_last_log_term(), current->get_last_log_idx(), current->get_last_log_term()); - return folly::makeSemiFuture< homestore::ReplResult< folly::Unit > >(folly::Unit{}); + if (m_snapshot_context != nullptr) { + auto current = dynamic_pointer_cast< homestore::nuraft_snapshot_context >(m_snapshot_context)->nuraft_snapshot(); + if (s->get_last_log_idx() < current->get_last_log_idx()) { + LOGI("Skipping create snapshot new idx/term: {}/{} current idx/term: {}/{}", s->get_last_log_idx(), + s->get_last_log_term(), current->get_last_log_idx(), current->get_last_log_term()); + return folly::makeSemiFuture< homestore::ReplResult< folly::Unit > >(folly::Unit{}); + } } LOGI("create snapshot last_log_idx: {} last_log_term: {}", s->get_last_log_idx(), s->get_last_log_term());