Skip to content

Commit

Permalink
fix/chunkserver: config change epoch update error
Browse files Browse the repository at this point in the history
  • Loading branch information
ilixiaocui committed Aug 5, 2021
1 parent 7c78889 commit 815da87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/chunkserver/copyset_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
&copysetDirPath_);
if (protocol.empty()) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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<std::mutex> lock_guard(confLock_);
conf_ = conf;
Expand Down
3 changes: 3 additions & 0 deletions test/chunkserver/heartbeat_test_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 815da87

Please sign in to comment.