HIVE-14784: Operation logs are disabled automatically if the parent directory does not exist. (Naveen Gangam via Yongzhi Chen)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/0562efce Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/0562efce Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/0562efce Branch: refs/heads/repl2 Commit: 0562efce642e70f1ac69eae6cca8c0a63230bafd Parents: 74a6ff6 Author: Yongzhi Chen <ych...@apache.org> Authored: Fri Sep 30 10:39:11 2016 -0400 Committer: Yongzhi Chen <ych...@apache.org> Committed: Fri Sep 30 10:41:37 2016 -0400 ---------------------------------------------------------------------- .../org/apache/hive/service/cli/operation/Operation.java | 11 +++++++++++ 1 file changed, 11 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/0562efce/service/src/java/org/apache/hive/service/cli/operation/Operation.java ---------------------------------------------------------------------- diff --git a/service/src/java/org/apache/hive/service/cli/operation/Operation.java b/service/src/java/org/apache/hive/service/cli/operation/Operation.java index 90fe76d..6a656f9 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/Operation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/Operation.java @@ -234,6 +234,17 @@ public abstract class Operation { operationLogFile.getAbsolutePath()); operationLogFile.delete(); } + if (!operationLogFile.getParentFile().exists()) { + LOG.warn("Operations log directory for this session does not exist, it could have been deleted " + + "externally. Recreating the directory for future queries in this session but the older operation " + + "logs for this session are no longer available"); + if (!operationLogFile.getParentFile().mkdir()) { + LOG.warn("Log directory for this session could not be created, disabling " + + "operation logs: " + operationLogFile.getParentFile().getAbsolutePath()); + isOperationLogEnabled = false; + return; + } + } if (!operationLogFile.createNewFile()) { // the log file already exists and cannot be deleted. // If it can be read/written, keep its contents and use it.