Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the error logging when the importer is not in a started state #2280

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/cluster/cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,24 +333,24 @@ Status Cluster::ImportSlot(redis::Connection *conn, int slot, int state) {
conn->SetImporting();
myself_->importing_slot = slot;
// Set link error callback
conn->close_cb = [object_ptr = srv_->slot_import.get()](int fd) {
conn->close_cb = [object_ptr = srv_->slot_import.get(), slot](int fd) {
auto s = object_ptr->StopForLinkError();
if (!s.IsOK()) {
LOG(ERROR) << "[import] Failed to stop importing slot: " << s.Msg();
LOG(ERROR) << fmt::format("[import] Failed to stop importing slot {}: {}", slot, s.Msg());
}
}; // Stop forbidding writing slot to accept write commands
if (slot == srv_->slot_migrator->GetForbiddenSlot()) srv_->slot_migrator->ReleaseForbiddenSlot();
LOG(INFO) << "[import] Start importing slot " << slot;
LOG(INFO) << fmt::format("[import] Start importing slot {}", slot);
break;
case kImportSuccess:
s = srv_->slot_import->Success(slot);
if (!s.IsOK()) return s;
LOG(INFO) << "[import] Mark the importing slot as succeed" << slot;
LOG(INFO) << fmt::format("[import] Mark the importing slot {} as succeed", slot);
break;
case kImportFailed:
s = srv_->slot_import->Fail(slot);
if (!s.IsOK()) return s;
LOG(INFO) << "[import] Mark the importing slot as failed" << slot;
LOG(INFO) << fmt::format("[import] Mark the importing slot {} as failed", slot);
break;
default:
return {Status::NotOK, errInvalidImportState};
Expand Down
3 changes: 2 additions & 1 deletion src/cluster/slot_import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ Status SlotImport::Fail(int slot) {

Status SlotImport::StopForLinkError() {
std::lock_guard<std::mutex> guard(mutex_);
if (import_status_ != kImportStart) return {Status::NotOK, "no slot is importing"};
// We don't need to do anything if the importer is not started yet.
if (import_status_ != kImportStart) return Status::OK();

// Maybe server has failovered
// Situation:
Expand Down
Loading