From 283bf43b9bb7f673eb49058f25374aaa419365c9 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 27 Aug 2024 12:42:34 +0200 Subject: CasClient: Fall back to single blob upload, if batch uploading made no progress We already accept short writes in batch uploads, but when no progress is made, we cannot simply retry, as this might lead to an infinite loop. Instead, we give up on batching and upload each blob one by one. --- .../execution_api/remote/bazel/bazel_cas_client.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp index aa6b7c9f..aac7f2a5 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp @@ -592,6 +592,20 @@ auto BazelCasClient::BatchUpdateBlobs( missing_blobs.begin(), missing_blobs.end()); } + if (result.empty() and missing > 0) { + // The batch upload did not make _any_ progress. So there is no value in + // trying that again; instead, we fall back to uploading each blob + // sequentially. + logger_.Emit(LogLevel::Debug, "Falling back to sequential blob upload"); + std::size_t count = 0; + std::for_each( + begin, end, [this, &count, &instance_name](auto const& blob) { + if (UpdateSingleBlob(instance_name, *blob)) { + count += 1; + } + }); + return count; + } return result.size(); } -- cgit v1.2.3