This is an automated email from the ASF dual-hosted git repository. abukor pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 243878d41a12c2b29a29c34c7c5f153610612a6f Author: Attila Bukor <[email protected]> AuthorDate: Wed Apr 1 10:06:38 2020 +0200 [subprocess] Fix shutdown behavior Prior to this commit the subprocess didn't actually shut down when its input stream was closed. This wasn't much of a problem on Linux where PDEATHSIG is set on the child process, but as it's not supported on Mac, whenever the master is shut down/crashes the subprocess stays alive. This commit changes the behavior to exit when the reader future exits (the loop is broken when EOF is received). Change-Id: Ia84bff891eaff667d7b22e89c66f24980ad76d70 Reviewed-on: http://gerrit.cloudera.org:8080/15615 Tested-by: Kudu Jenkins Reviewed-by: Hao Hao <[email protected]> Reviewed-by: Adar Dembo <[email protected]> --- java/config/spotbugs/excludeFilter.xml | 8 +++++++- .../main/java/org/apache/kudu/subprocess/SubprocessExecutor.java | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/java/config/spotbugs/excludeFilter.xml b/java/config/spotbugs/excludeFilter.xml index 676b885..d570244 100644 --- a/java/config/spotbugs/excludeFilter.xml +++ b/java/config/spotbugs/excludeFilter.xml @@ -307,6 +307,12 @@ <Bug pattern="MS_MUTABLE_ARRAY" /> </Match> <Match> + <!-- We need to exit instead of throwing RuntimeException to make sure + all threads stop --> + <Class name="org.apache.kudu.subprocess.SubprocessExecutor"/> + <Bug pattern="DM_EXIT"/> + </Match> + <Match> <!-- This is done to simplify testing. --> <Class name="org.apache.kudu.subprocess.ranger.TestRangerSubprocess"/> <Method name="mockAuthorizer" /> @@ -329,4 +335,4 @@ <Class name="org.apache.kudu.test.cluster.FakeDNS"/> <Bug pattern="DP_DO_INSIDE_DO_PRIVILEGED" /> </Match> -</FindBugsFilter> \ No newline at end of file +</FindBugsFilter> diff --git a/java/kudu-subprocess/src/main/java/org/apache/kudu/subprocess/SubprocessExecutor.java b/java/kudu-subprocess/src/main/java/org/apache/kudu/subprocess/SubprocessExecutor.java index 1363ea0..6d6cccc 100644 --- a/java/kudu-subprocess/src/main/java/org/apache/kudu/subprocess/SubprocessExecutor.java +++ b/java/kudu-subprocess/src/main/java/org/apache/kudu/subprocess/SubprocessExecutor.java @@ -111,6 +111,11 @@ public class SubprocessExecutor { MessageReader reader = new MessageReader(inboundQueue, messageIO, injectInterrupt); CompletableFuture<Void> readerFuture = CompletableFuture.runAsync(reader, readerService); readerFuture.exceptionally(errorHandler); + // Force the program to exit when reader future completes. + // + // TODO(abukor): Refactor code so the futures can be cancelled instead + // of having to call System.exit() + readerFuture = readerFuture.thenRun(() -> System.exit(0)); // Start multiple message parser threads and run the tasks asynchronously. MessageParser parser = new MessageParser(inboundQueue, outboundQueue, protocolHandler);
