Skip to content

Commit d184e48

Browse files
mostynbcopybara-github
authored andcommitted
Remote: handle early return of compressed blobs uploads
This is an implementation of this REAPI spec update: bazelbuild/remote-apis#213 Here's a bazel-remote build that can be used to test this change: buchgr/bazel-remote#527 Fixes #14654 Closes #14870. PiperOrigin-RevId: 430167812
1 parent 3fd0ffa commit d184e48

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

CONTRIBUTORS

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Shreya Bhattarai <[email protected]>
2020
Kevin Bierhoff <[email protected]>
2121
Klaas Boesche <[email protected]>
2222
Phil Bordelon <[email protected]>
23+
Mostyn Bramley-Moore <[email protected]>
2324
Jon Brandvein <[email protected]>
2425
Volker Braun <[email protected]>
2526
Thomas Broyer <[email protected]>

src/main/java/com/google/devtools/build/lib/remote/ByteStreamUploader.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,33 @@ ListenableFuture<Void> start() {
323323
// level/algorithm, so we cannot know the expected committed offset
324324
long committedSize = committedOffset.get();
325325
long expected = chunker.getOffset();
326-
if (!chunker.hasNext() && committedSize != expected) {
326+
327+
if (committedSize == expected) {
328+
// Both compressed and uncompressed uploads can succeed
329+
// with this result.
330+
return immediateVoidFuture();
331+
}
332+
333+
if (chunker.isCompressed()) {
334+
if (committedSize == -1) {
335+
// Returned early, blob already available.
336+
return immediateVoidFuture();
337+
}
338+
327339
String message =
328340
format(
329-
"write incomplete: committed_size %d for %d total",
341+
"compressed write incomplete: committed_size %d is neither -1 nor total %d",
330342
committedSize, expected);
331343
return Futures.immediateFailedFuture(new IOException(message));
332344
}
345+
346+
// Uncompressed upload failed.
347+
String message =
348+
format(
349+
"write incomplete: committed_size %d for %d total", committedSize, expected);
350+
return Futures.immediateFailedFuture(new IOException(message));
333351
}
352+
334353
return immediateVoidFuture();
335354
},
336355
MoreExecutors.directExecutor());

0 commit comments

Comments
 (0)