You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2019/01/28 11:19:32 UTC

[GitHub] arina-ielchiieva commented on a change in pull request #1625: DRILL-7008: Drillbits: clear stale shutdown hooks

arina-ielchiieva commented on a change in pull request #1625: DRILL-7008: Drillbits: clear stale shutdown hooks
URL: https://github.com/apache/drill/pull/1625#discussion_r251373908
 
 

 ##########
 File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
 ##########
 @@ -258,6 +260,13 @@ public synchronized void close() {
     }
     final Stopwatch w = Stopwatch.createStarted();
     logger.debug("Shutdown begun.");
+    // We don't really want for Drillbits to pile up in memory, so the hook should be removed
+    // It might be better to use PhantomReferences to cleanup as soon as Drillbit becomes
+    // unreachable, however current approach seems to be good enough.
+    Thread shutdownHook = this.shutdownHook;
+    if (shutdownHook != null && Thread.currentThread() != shutdownHook) {
+      Runtime.getRuntime().removeShutdownHook(shutdownHook);
 
 Review comment:
   @vlsi `removeShutdownHook` can throw `IllegalStateException` if the virtual machine is already in the process of shutting down. Maybe we should add try / catch block to ignore such exception?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services