From 815da874df7e766bc57c95a28925a035b17a7c20 Mon Sep 17 00:00:00 2001 From: lixiaocui1 Date: Thu, 5 Aug 2021 15:01:06 +0800 Subject: [PATCH] fix/chunkserver: config change epoch update error --- src/chunkserver/copyset_node.cpp | 7 +++++++ test/chunkserver/heartbeat_test_common.cpp | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/chunkserver/copyset_node.cpp b/src/chunkserver/copyset_node.cpp index ee31dfc25e..38b99335a7 100755 --- a/src/chunkserver/copyset_node.cpp +++ b/src/chunkserver/copyset_node.cpp @@ -85,6 +85,8 @@ CopysetNode::~CopysetNode() { int CopysetNode::Init(const CopysetNodeOptions &options) { std::string groupId = GroupId(); + lastSnapshotIndex_ = 0; + std::string protocol = UriParser::ParseUri(options.chunkDataUri, ©setDirPath_); if (protocol.empty()) { @@ -434,7 +436,10 @@ int CopysetNode::on_snapshot_load(::braft::SnapshotReader *reader) { conf_.add_peer(meta.peers(i)); } } + + LOG(INFO) << "update lastSnapshotIndex_ from " << lastSnapshotIndex_; lastSnapshotIndex_ = meta.last_included_index(); + LOG(INFO) << "to lastSnapshotIndex_: " << lastSnapshotIndex_; return 0; } @@ -465,6 +470,8 @@ void CopysetNode::on_configuration_committed(const Configuration& conf, // This function is also called when loading snapshot. // Loading snapshot should not increase epoch. When loading // snapshot, the index is equal with lastSnapshotIndex_. + LOG(INFO) << "index: " << index + << ", lastSnapshotIndex_: " << lastSnapshotIndex_; if (index != lastSnapshotIndex_) { std::unique_lock lock_guard(confLock_); conf_ = conf; diff --git a/test/chunkserver/heartbeat_test_common.cpp b/test/chunkserver/heartbeat_test_common.cpp index 553e84b0ad..146d354ac9 100644 --- a/test/chunkserver/heartbeat_test_common.cpp +++ b/test/chunkserver/heartbeat_test_common.cpp @@ -351,6 +351,9 @@ bool HeartbeatTestCommon::WailForConfigChangeOk( if (SameCopySetInfo(req->copysetinfos(0), expectedInfo)) { return true; } + LOG(INFO) << "req->copysetinfos:" + << req->copysetinfos(0).DebugString() + << ", expectedInfo: " << expectedInfo.DebugString(); } else if (req->copysetinfos_size() == 0) { if (SameCopySetInfo( ::curve::mds::heartbeat::CopySetInfo{}, expectedInfo)) {