From 8c0f9480549a4e7fa7de02c9bf73bccb0381f22a Mon Sep 17 00:00:00 2001 From: July <51110188+yikf@users.noreply.github.com> Date: Sat, 5 Jun 2021 04:36:09 +0800 Subject: [PATCH] HDFS-16033 Fix issue of the StatisticsDataReferenceCleaner cleanUp (#3042) Contributed by kaifeiYi (yikf). Signed-off-by: Mingliang Liu Reviewed-by: Steve Loughran --- .../src/main/java/org/apache/hadoop/fs/FileSystem.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java index 528f6c270f4..e3c8d0dd3fd 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java @@ -4013,12 +4013,19 @@ public abstract class FileSystem extends Configured * Background action to act on references being removed. */ private static class StatisticsDataReferenceCleaner implements Runnable { + /** + * Represents the timeout period expires for remove reference objects from + * the STATS_DATA_REF_QUEUE when the queue is empty. + */ + private static final int REF_QUEUE_POLL_TIMEOUT = 10000; + @Override public void run() { while (!Thread.interrupted()) { try { StatisticsDataReference ref = - (StatisticsDataReference)STATS_DATA_REF_QUEUE.remove(); + (StatisticsDataReference)STATS_DATA_REF_QUEUE. + remove(REF_QUEUE_POLL_TIMEOUT); ref.cleanUp(); } catch (InterruptedException ie) { LOGGER.warn("Cleaner thread interrupted, will stop", ie);