From 349f97a0e06d637b66f8b8e7134ee1de89ac7f1e Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Sat, 13 Jan 2024 17:11:24 +0800 Subject: [PATCH] fix: if resp->code() != RsyncService::kOk should set SyncSlaveSlot repl_state_ to kError(#2299) (#2315) Co-authored-by: liuchengyu --- src/pika_rm.cc | 2 ++ src/rsync_client.cc | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pika_rm.cc b/src/pika_rm.cc index b93f75f757..e6d6bbb0a1 100644 --- a/src/pika_rm.cc +++ b/src/pika_rm.cc @@ -644,6 +644,8 @@ void SyncSlaveSlot::ActivateRsync() { LOG(WARNING) << "ActivateRsync ..."; if (rsync_cli_->Init()) { rsync_cli_->Start(); + } else { + SetReplState(ReplState::kError); } } diff --git a/src/rsync_client.cc b/src/rsync_client.cc index 12da1ddad5..a833b109f8 100644 --- a/src/rsync_client.cc +++ b/src/rsync_client.cc @@ -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; } @@ -338,15 +338,15 @@ Status RsyncClient::CopyRemoteMeta(std::string* snapshot_uuid, std::set 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() @@ -356,6 +356,7 @@ Status RsyncClient::CopyRemoteMeta(std::string* snapshot_uuid, std::setsnapshot_uuid(); + s = Status::OK(); break; } return s;