Skip to content

Commit b55f322

Browse files
authored
Fix hanging issue when Bazel failed to upload action inputs (#16819)
Fixes #16422. Closes #16423. Closes #16445. Closes #16464. PiperOrigin-RevId: 480896881 Change-Id: I33019dbe8a088410280759465100a512a0f61bc1
1 parent 42a3dbb commit b55f322

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

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

-5
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,6 @@ public void onComplete() {
222222

223223
@Override
224224
public void onError(@NonNull Throwable e) {
225-
Disposable d = uploadTask.disposable.get();
226-
if (d != null && d.isDisposed()) {
227-
return;
228-
}
229-
230225
completion.onError(e);
231226
}
232227
});

src/test/java/com/google/devtools/build/lib/remote/RemoteCacheTest.java

+26
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.google.common.collect.ImmutableList;
2626
import com.google.common.collect.ImmutableMap;
2727
import com.google.common.collect.ImmutableSet;
28+
import com.google.common.collect.ImmutableSortedMap;
29+
import com.google.common.util.concurrent.Futures;
2830
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
2931
import com.google.common.util.concurrent.MoreExecutors;
3032
import com.google.common.util.concurrent.SettableFuture;
@@ -71,6 +73,7 @@
7173
import java.util.concurrent.Executors;
7274
import java.util.concurrent.TimeUnit;
7375
import org.junit.After;
76+
import org.junit.Assert;
7477
import org.junit.Before;
7578
import org.junit.Rule;
7679
import org.junit.Test;
@@ -435,6 +438,29 @@ public void ensureInputsPresent_interruptedDuringUploadBlobs_cancelInProgressUpl
435438
assertThat(remoteCache.casUploadCache.getFinishedTasks()).hasSize(2);
436439
}
437440

441+
@Test
442+
public void ensureInputsPresent_uploadFailed_propagateErrors() throws Exception {
443+
RemoteCacheClient cacheProtocol = spy(new InMemoryCacheClient());
444+
doAnswer(invocationOnMock -> Futures.immediateFailedFuture(new IOException("upload failed")))
445+
.when(cacheProtocol)
446+
.uploadBlob(any(), any(), any());
447+
doAnswer(invocationOnMock -> Futures.immediateFailedFuture(new IOException("upload failed")))
448+
.when(cacheProtocol)
449+
.uploadFile(any(), any(), any());
450+
RemoteExecutionCache remoteCache = spy(newRemoteExecutionCache(cacheProtocol));
451+
Path path = fs.getPath("/execroot/foo");
452+
FileSystemUtils.writeContentAsLatin1(path, "bar");
453+
SortedMap<PathFragment, Path> inputs = ImmutableSortedMap.of(PathFragment.create("foo"), path);
454+
MerkleTree merkleTree = MerkleTree.build(inputs, digestUtil);
455+
456+
IOException e =
457+
Assert.assertThrows(
458+
IOException.class,
459+
() -> remoteCache.ensureInputsPresent(context, merkleTree, ImmutableMap.of(), false));
460+
461+
assertThat(e).hasMessageThat().contains("upload failed");
462+
}
463+
438464
private InMemoryRemoteCache newRemoteCache() {
439465
RemoteOptions options = Options.getDefaults(RemoteOptions.class);
440466
return new InMemoryRemoteCache(options, digestUtil);

0 commit comments

Comments
 (0)