This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 9d9dff26 Fix the error logging when the importer is not in a started 
state (#2280)
9d9dff26 is described below

commit 9d9dff26d53579c7816c7b8050cf2272c1ed0ccf
Author: hulk <[email protected]>
AuthorDate: Mon Apr 29 13:25:40 2024 +0800

    Fix the error logging when the importer is not in a started state (#2280)
---
 src/cluster/cluster.cc     | 10 +++++-----
 src/cluster/slot_import.cc |  3 ++-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/cluster/cluster.cc b/src/cluster/cluster.cc
index 74aec5d0..8bdf9095 100644
--- a/src/cluster/cluster.cc
+++ b/src/cluster/cluster.cc
@@ -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};
diff --git a/src/cluster/slot_import.cc b/src/cluster/slot_import.cc
index dcc97d66..4306e336 100644
--- a/src/cluster/slot_import.cc
+++ b/src/cluster/slot_import.cc
@@ -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:

Reply via email to