From 3d2ef54450f1066c56bd97daa8a0508d594fc181 Mon Sep 17 00:00:00 2001 From: Junping Du Date: Mon, 16 Oct 2017 13:57:03 -0700 Subject: [PATCH] YARN-7124. LogAggregationTFileController deletes/renames while file is open. Contributed by Jason Lowe. (cherry picked from commit 1fcbe7cf5f2f7c609cd4158912f151848268ca9e) --- .../tfile/LogAggregationTFileController.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/tfile/LogAggregationTFileController.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/tfile/LogAggregationTFileController.java index 92e3a08da39..5064e267f4f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/tfile/LogAggregationTFileController.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/tfile/LogAggregationTFileController.java @@ -96,8 +96,10 @@ public class LogAggregationTFileController @Override public void closeWriter() { - this.writer.close(); - this.writer = null; + if (this.writer != null) { + this.writer.close(); + this.writer = null; + } } @Override @@ -117,6 +119,9 @@ public class LogAggregationTFileController record.increcleanupOldLogTimes(); } + // close the writer before the file is renamed or deleted + closeWriter(); + final Path renamedPath = record.getRollingMonitorInterval() <= 0 ? record.getRemoteNodeLogFileForApp() : new Path( record.getRemoteNodeLogFileForApp().getParent(),