From 335d1a1b7005366b119fae1ff877a352b68dcbb7 Mon Sep 17 00:00:00 2001 From: JinYan Su <751080330@qq.com> Date: Wed, 13 Aug 2025 11:29:58 +0800 Subject: [PATCH] fix(store): replace CHECK with error handling (#735) --- mooncake-store/include/transfer_task.h | 5 +---- mooncake-store/src/client.cpp | 5 ++++- mooncake-store/src/transfer_task.cpp | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/mooncake-store/include/transfer_task.h b/mooncake-store/include/transfer_task.h index c88c8863..753fef76 100644 --- a/mooncake-store/include/transfer_task.h +++ b/mooncake-store/include/transfer_task.h @@ -157,10 +157,7 @@ class TransferEngineOperationState : public OperationState { public: TransferEngineOperationState(TransferEngine& engine, BatchID batch_id, size_t batch_size) - : engine_(engine), batch_id_(batch_id), batch_size_(batch_size) { - CHECK(batch_id_ != Transport::INVALID_BATCH_ID) - << "Invalid batch ID for transfer engine operation"; - } + : engine_(engine), batch_id_(batch_id), batch_size_(batch_size) {} ~TransferEngineOperationState() { engine_.freeBatchID(batch_id_); } diff --git a/mooncake-store/src/client.cpp b/mooncake-store/src/client.cpp index 33a8d799..6e73df11 100644 --- a/mooncake-store/src/client.cpp +++ b/mooncake-store/src/client.cpp @@ -203,7 +203,10 @@ ErrorCode Client::InitTransferEngine(const std::string& local_hostname, auto [hostname, port] = parseHostNameWithPort(local_hostname); int rc = transfer_engine_.init(metadata_connstring, local_hostname, hostname, port); - CHECK_EQ(rc, 0) << "Failed to initialize transfer engine"; + if (rc != 0) { + LOG(ERROR) << "Failed to initialize transfer engine, rc=" << rc; + return ErrorCode::INTERNAL_ERROR; + } Transport* transport = nullptr; if (protocol == "rdma") { diff --git a/mooncake-store/src/transfer_task.cpp b/mooncake-store/src/transfer_task.cpp index 4ce4dbbe..f35b84c5 100644 --- a/mooncake-store/src/transfer_task.cpp +++ b/mooncake-store/src/transfer_task.cpp @@ -509,6 +509,11 @@ std::optional TransferSubmitter::submitTransferEngineOperation( return std::nullopt; } + if (batch_id == Transport::INVALID_BATCH_ID) { + LOG(ERROR) << "Invalid batch ID for transfer engine operation"; + return std::nullopt; + } + // Create state with transfer engine context - no polling thread // needed auto state = std::make_shared(