Skip to content

Commit

Permalink
fix: if resp->code() != RsyncService::kOk should set SyncSlaveSlot re…
Browse files Browse the repository at this point in the history
…pl_state_ to kError(OpenAtomFoundation#2299) (OpenAtomFoundation#2315)

Co-authored-by: liuchengyu <[email protected]>
  • Loading branch information
chengyu-l and liuchengyu authored Jan 13, 2024
1 parent f22d103 commit 2540251
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/pika_rm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,8 @@ void SyncSlaveSlot::ActivateRsync() {
LOG(WARNING) << "ActivateRsync ...";
if (rsync_cli_->Init()) {
rsync_cli_->Start();
} else {
SetReplState(ReplState::kError);
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/rsync_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ bool RsyncClient::Recover() {

Status s = CopyRemoteMeta(&remote_snapshot_uuid, &remote_file_set);
if (!s.ok()) {
LOG(WARNING) << "copy remote meta failed";
LOG(WARNING) << "copy remote meta failed! error:" << s.ToString();
return false;
}

Expand Down Expand Up @@ -338,15 +338,15 @@ Status RsyncClient::CopyRemoteMeta(std::string* snapshot_uuid, std::set<std::str
}
std::shared_ptr<RsyncResponse> resp;
s = wo->Wait(resp);
if (s.IsTimeout() || resp.get() == nullptr) {
if (s.IsTimeout()) {
LOG(WARNING) << "rsync CopyRemoteMeta request timeout, "
<< "retry times: " << retries;
retries++;
continue;
}

if (resp->code() != RsyncService::kOk) {
//TODO: handle different error
if (resp.get() == nullptr || resp->code() != RsyncService::kOk) {
s = Status::IOError("kRsyncMeta request failed! unknown reason");
continue;
}
LOG(INFO) << "receive rsync meta infos, snapshot_uuid: " << resp->snapshot_uuid()
Expand All @@ -356,6 +356,7 @@ Status RsyncClient::CopyRemoteMeta(std::string* snapshot_uuid, std::set<std::str
}

*snapshot_uuid = resp->snapshot_uuid();
s = Status::OK();
break;
}
return s;
Expand Down

0 comments on commit 2540251

Please sign in to comment.