From d82341d508829c43ab6408910f0b03cacf5b03b2 Mon Sep 17 00:00:00 2001 From: adgar Date: Fri, 10 Apr 2020 10:05:24 -0700 Subject: [PATCH] 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 --- .../lib/remote/ByteStreamBuildEventArtifactUploader.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 107023c81eca4a..3a03343e3e8bc4 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 @@ class ByteStreamBuildEventArtifactUploader implements BuildEventArtifactUploader // 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 @@ public void shutdown() { return; } uploader.release(); + uploadExecutor.shutdown(); } private static class PathConverterImpl implements PathConverter {