From 79e496575bf665e4436b242b890590ddfc2f549b Mon Sep 17 00:00:00 2001 From: Nathan Harmata Date: Fri, 16 Dec 2016 22:00:48 +0000 Subject: Add some logging when query evaluation halts abruptly. -- PiperOrigin-RevId: 142295816 MOS_MIGRATED_REVID=142295816 --- .../devtools/build/lib/query2/SkyQueryEnvironment.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java index 9a52eba825..d37367da67 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java @@ -18,6 +18,7 @@ import com.google.common.base.Ascii; import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.base.Throwables; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; @@ -106,6 +107,7 @@ import java.util.Queue; import java.util.Set; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable; @@ -332,20 +334,24 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment protected void evalTopLevelInternal( QueryExpression expr, OutputFormatterCallback callback) throws QueryException, InterruptedException { - boolean poolNeedsShutdown = true; + Throwable throwableToThrow = null; try { super.evalTopLevelInternal(expr, callback); - poolNeedsShutdown = false; + } catch (Throwable throwable) { + throwableToThrow = throwable; } finally { - if (poolNeedsShutdown) { + if (throwableToThrow != null) { + LOG.log(Level.INFO, "About to shutdown FJP because of throwable", throwableToThrow); // Force termination of remaining tasks if evaluation failed abruptly (e.g. was // interrupted). We don't want to leave any dangling threads running tasks. forkJoinPool.shutdownNow(); } forkJoinPool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS); - if (poolNeedsShutdown) { + if (throwableToThrow != null) { // Signal that pool must be recreated on the next invocation. forkJoinPool = null; + Throwables.propagateIfPossible( + throwableToThrow, QueryException.class, InterruptedException.class); } } } -- cgit v1.2.3