HDFS-7922. ShortCircuitCache#close is not releasing ScheduledThreadPoolExecutors (Rakesh R via Colin P. McCabe)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/093e0925 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/093e0925 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/093e0925 Branch: refs/heads/YARN-2928 Commit: 093e0925a4459bb07e4093a30455016a815734d5 Parents: f4afce0 Author: Colin Patrick Mccabe <cmcc...@cloudera.com> Authored: Wed Apr 1 16:02:39 2015 -0700 Committer: Zhijie Shen <zjs...@apache.org> Committed: Mon Apr 6 12:08:12 2015 -0700 ---------------------------------------------------------------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/shortcircuit/ShortCircuitCache.java | 28 ++++++++++++++++++++ .../shortcircuit/TestShortCircuitCache.java | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/093e0925/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index b5591e0..f265ead 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -409,6 +409,9 @@ Release 2.8.0 - UNRELEASED HDFS-6945. BlockManager should remove a block from excessReplicateMap and decrement ExcessBlocks metric when the block is removed. (aajisaka) + HDFS-7922. ShortCircuitCache#close is not releasing + ScheduledThreadPoolExecutors (Rakesh R via Colin P. McCabe) + Release 2.7.0 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/093e0925/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitCache.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitCache.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitCache.java index 73c52d5..d1ec3b8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitCache.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitCache.java @@ -916,6 +916,34 @@ public class ShortCircuitCache implements Closeable { } finally { lock.unlock(); } + + releaserExecutor.shutdown(); + cleanerExecutor.shutdown(); + // wait for existing tasks to terminate + try { + if (!releaserExecutor.awaitTermination(30, TimeUnit.SECONDS)) { + LOG.error("Forcing SlotReleaserThreadPool to shutdown!"); + releaserExecutor.shutdownNow(); + } + } catch (InterruptedException e) { + releaserExecutor.shutdownNow(); + Thread.currentThread().interrupt(); + LOG.error("Interrupted while waiting for SlotReleaserThreadPool " + + "to terminate", e); + } + + // wait for existing tasks to terminate + try { + if (!cleanerExecutor.awaitTermination(30, TimeUnit.SECONDS)) { + LOG.error("Forcing CleanerThreadPool to shutdown!"); + cleanerExecutor.shutdownNow(); + } + } catch (InterruptedException e) { + cleanerExecutor.shutdownNow(); + Thread.currentThread().interrupt(); + LOG.error("Interrupted while waiting for CleanerThreadPool " + + "to terminate", e); + } IOUtils.cleanup(LOG, shmManager); } http://git-wip-us.apache.org/repos/asf/hadoop/blob/093e0925/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitCache.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitCache.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitCache.java index 7daabd0..7d26dee 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitCache.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitCache.java @@ -203,7 +203,7 @@ public class TestShortCircuitCache { cache.close(); } - @Test(timeout=60000) + @Test(timeout=100000) public void testExpiry() throws Exception { final ShortCircuitCache cache = new ShortCircuitCache(2, 1, 1, 10000000, 1, 10000000, 0);