Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 68D44200D34 for ; Fri, 3 Nov 2017 21:58:21 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 674C3160BFB; Fri, 3 Nov 2017 20:58:21 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AE26C160BDE for ; Fri, 3 Nov 2017 21:58:20 +0100 (CET) Received: (qmail 37624 invoked by uid 500); 3 Nov 2017 20:58:19 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 37607 invoked by uid 99); 3 Nov 2017 20:58:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Nov 2017 20:58:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 21970DFF7C; Fri, 3 Nov 2017 20:58:17 +0000 (UTC) From: Ben-Zvi To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request #1023: DRILL-5922 Fixed Child Allocator Leak. DRILL-5926 ... Content-Type: text/plain Message-Id: <20171103205818.21970DFF7C@git1-us-west.apache.org> Date: Fri, 3 Nov 2017 20:58:17 +0000 (UTC) archived-at: Fri, 03 Nov 2017 20:58:21 -0000 Github user Ben-Zvi commented on a diff in the pull request: https://github.com/apache/drill/pull/1023#discussion_r148890716 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java --- @@ -158,38 +165,51 @@ public DrillbitContext getContext() { return dContext; } - private ExtendedLatch exitLatch = null; // used to wait to exit when things are still running - /** * Waits until it is safe to exit. Blocks until all currently running fragments have completed. - * - *

This is intended to be used by {@link org.apache.drill.exec.server.Drillbit#close()}.

+ * This is intended to be used by {@link org.apache.drill.exec.server.Drillbit#close()}. */ public void waitToExit() { - synchronized(this) { - if (queries.isEmpty() && runningFragments.isEmpty()) { - return; + final long startTime = System.currentTimeMillis(); + + try { + exitLock.lock(); + long diff; + while ((diff = (System.currentTimeMillis() - startTime)) < EXIT_TIMEOUT) { + if (queries.isEmpty() && runningFragments.isEmpty()) { + break; + } + + try { + final boolean success = exitCondition.await(EXIT_TIMEOUT - diff, TimeUnit.MILLISECONDS); + + if (!success) { + logger.warn("Timed out after %d millis while waiting to exit.", EXIT_TIMEOUT); + exitLock.lock(); + } + } catch (InterruptedException e) { + logger.warn("Interrupted while waiting to exit"); + exitLock.lock(); --- End diff -- 1. Why calling lock() here ? 2. Should the code issue an error instead of a warning ? ---