Skip to content
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
29 changes: 27 additions & 2 deletions mooncake-store/src/client_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,7 @@ tl::expected<void, ErrorCode> Client::Put(const ObjectKey& key,
auto checksum_result = ComputeObjectChecksumForSlices(
key, slices, CalculateSliceSize(slices));
if (!checksum_result) {
pt_full.End(-1);
return tl::unexpected(checksum_result.error());
}
object_checksum = *checksum_result;
Expand All @@ -1719,6 +1720,7 @@ tl::expected<void, ErrorCode> Client::Put(const ObjectKey& key,
ErrorCode err = start_result.error();
if (err == ErrorCode::OBJECT_ALREADY_EXISTS) {
VLOG(1) << "object_already_exists key=" << key;
pt_full.End(0);
return {};
}
if (err == ErrorCode::NO_AVAILABLE_HANDLE) {
Expand All @@ -1728,6 +1730,7 @@ tl::expected<void, ErrorCode> Client::Put(const ObjectKey& key,
LOG(ERROR) << "Failed to start put operation for key=" << key
<< ": " << toString(err);
}
pt_full.End(-1);
return tl::unexpected(err);
}

Expand Down Expand Up @@ -1789,6 +1792,7 @@ tl::expected<void, ErrorCode> Client::Put(const ObjectKey& key,
if (!end_result) {
ErrorCode err = end_result.error();
LOG(ERROR) << "Failed to end put operation: " << err;
pt_full.End(-1);
return tl::unexpected(err);
}
}
Expand All @@ -1798,14 +1802,17 @@ tl::expected<void, ErrorCode> Client::Put(const ObjectKey& key,
master_client_.PutRevoke(key, *finalize_decision.revoke_type);
if (!revoke_result) {
LOG(ERROR) << "Failed to revoke put operation";
pt_full.End(-1);
return tl::unexpected(revoke_result.error());
}
}

if (!finalize_decision.success) {
pt_full.End(-1);
return tl::unexpected(finalize_decision.error);
}

pt_full.End(0);
return {};
}

Expand Down Expand Up @@ -2138,9 +2145,15 @@ void Client::StartBatchPut(std::vector<PutOperation>& ops,
op.SetError(ErrorCode::RPC_FAIL,
"BatchPutStart response size mismatch");
}
pt_batch_start.End(-1);
return;
}

const bool any_start_succeeded =
std::any_of(start_responses.begin(), start_responses.end(),
[](const auto& response) { return response.has_value(); });
pt_batch_start.End(any_start_succeeded ? 0 : -1);

// Process individual responses with robust error handling
for (size_t i = 0; i < active_indices.size(); ++i) {
auto& op = ops[active_indices[i]];
Expand Down Expand Up @@ -2828,17 +2841,24 @@ std::vector<tl::expected<void, ErrorCode>> Client::BatchPut(
if (client_cfg.nof_replica_num > 0) {
LOG(ERROR) << "prefer_alloc_in_same_node is not supported with "
"NoF replicas";
pt_full.End(-1);
return std::vector<tl::expected<void, ErrorCode>>(
keys.size(), tl::unexpected(ErrorCode::INVALID_PARAMS));
}
if (client_cfg.replica_num != 1) {
LOG(ERROR) << "prefer_alloc_in_same_node is not supported with "
"replica_num != 1";
pt_full.End(-1);
return std::vector<tl::expected<void, ErrorCode>>(
keys.size(), tl::unexpected(ErrorCode::INVALID_PARAMS));
}
StartBatchPut(ops, client_cfg);
return BatchPutWhenPreferSameNode(ops);
auto results = BatchPutWhenPreferSameNode(ops);
const bool any_succeeded =
std::any_of(results.begin(), results.end(),
[](const auto& result) { return result.has_value(); });
pt_full.End(any_succeeded ? 0 : -1);
return results;
}
StartBatchPut(ops, client_cfg);

Expand All @@ -2853,7 +2873,12 @@ std::vector<tl::expected<void, ErrorCode>> Client::BatchPut(
}

FinalizeBatchPut(ops);
return CollectResults(ops);
auto results = CollectResults(ops);
const bool any_succeeded =
std::any_of(results.begin(), results.end(),
[](const auto& result) { return result.has_value(); });
pt_full.End(any_succeeded ? 0 : -1);
return results;
}

tl::expected<void, ErrorCode> Client::Remove(const ObjectKey& key, bool force) {
Expand Down
1 change: 1 addition & 0 deletions mooncake-store/src/master_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9400,6 +9400,7 @@ void MasterService::ClientMonitorFunc() {
}
}
RecomputeTenantEffectiveQuotas();
pt_unmount.End(0);
}

pt_monitor.End(0);
Expand Down
Loading