Shutdown ByteStream BES artifact uploader threadpool after build.
When bazel is configured to upload BES artifacts (eg.
command.profile.gz) using a grpc endpoint, we create a thread pool
dedicated to uploading files for that build. With this change we now
remember to shutdown the threadpool after the build completes.
Fixes #10603.
PiperOrigin-RevId: 305895285
diff --git a/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java b/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java
index 107023c..3a03343 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java
@@ -24,6 +24,7 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.devtools.build.lib.buildeventstream.BuildEvent.LocalFile;
import com.google.devtools.build.lib.buildeventstream.BuildEventArtifactUploader;
import com.google.devtools.build.lib.buildeventstream.PathConverter;
@@ -73,7 +74,9 @@
// Limit the maximum threads number to 1000 (chosen arbitrarily)
this.uploadExecutor =
MoreExecutors.listeningDecorator(
- Executors.newFixedThreadPool(Math.min(maxUploadThreads, 1000)));
+ Executors.newFixedThreadPool(
+ Math.min(maxUploadThreads, 1000),
+ new ThreadFactoryBuilder().setNameFormat("bes-artifact-uploader-%d").build()));
this.missingDigestsFinder = missingDigestsFinder;
}
@@ -250,6 +253,7 @@
return;
}
uploader.release();
+ uploadExecutor.shutdown();
}
private static class PathConverterImpl implements PathConverter {