You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ay...@apache.org on 2022/11/02 08:59:50 UTC

[hive] branch master updated: HIVE-25585: Put dagId to MDC once it's available (#3702). (Laszlo Bodor reviewed by Ayush Saxena)

This is an automated email from the ASF dual-hosted git repository.

ayushsaxena pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new c9e9d5d542e HIVE-25585: Put dagId to MDC once it's available (#3702). (Laszlo Bodor reviewed by Ayush Saxena)
c9e9d5d542e is described below

commit c9e9d5d542e382d2322f2ca527a7d5a36d66ffa9
Author: Bodor Laszlo <bo...@gmail.com>
AuthorDate: Wed Nov 2 09:59:38 2022 +0100

    HIVE-25585: Put dagId to MDC once it's available (#3702). (Laszlo Bodor reviewed by Ayush Saxena)
---
 common/src/java/org/apache/hadoop/hive/common/LogUtils.java | 5 +++++
 ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezTask.java | 6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/common/src/java/org/apache/hadoop/hive/common/LogUtils.java b/common/src/java/org/apache/hadoop/hive/common/LogUtils.java
index f7571c6c7dc..afe6607298a 100644
--- a/common/src/java/org/apache/hadoop/hive/common/LogUtils.java
+++ b/common/src/java/org/apache/hadoop/hive/common/LogUtils.java
@@ -58,6 +58,7 @@ public class LogUtils {
    */
   public static final String SESSIONID_LOG_KEY = "sessionId";
   public static final String QUERYID_LOG_KEY = "queryId";
+  public static final String DAGID_KEY = "dagId";
   public static final String OPERATIONLOG_LEVEL_KEY = "operationLogLevel";
   public static final String OPERATIONLOG_LOCATION_KEY = "operationLogLocation";
 
@@ -232,6 +233,7 @@ public class LogUtils {
     // Remove the keys added, don't use clear, as it may clear all other things which are not intended to be removed.
     MDC.remove(SESSIONID_LOG_KEY);
     MDC.remove(QUERYID_LOG_KEY);
+    MDC.remove(DAGID_KEY); // it was put by TezTask after submitting DAG
     MDC.remove(OPERATIONLOG_LEVEL_KEY);
     MDC.remove(OPERATIONLOG_LOCATION_KEY);
     l4j.info("Unregistered logging context.");
@@ -259,4 +261,7 @@ public class LogUtils {
     return logFilePath;
   }
 
+  public static void putToMDC(String key, String value) {
+    MDC.put(key, value);
+  }
 }
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezTask.java
index 66db1676b30..0cb240670ee 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezTask.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezTask.java
@@ -18,7 +18,6 @@
 
 package org.apache.hadoop.hive.ql.exec.tez;
 
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.ql.session.SessionStateUtil;
 import org.apache.hive.common.util.Ref;
 import org.apache.hadoop.hive.ql.exec.tez.UserPoolMapping.MappingInput;
@@ -39,6 +38,7 @@ import javax.annotation.Nullable;
 import org.apache.hadoop.classification.InterfaceAudience.Private;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.common.LogUtils;
 import org.apache.hadoop.hive.common.ServerUtils;
 import org.apache.hadoop.hive.common.metrics.common.Metrics;
 import org.apache.hadoop.hive.common.metrics.common.MetricsConstant;
@@ -249,8 +249,10 @@ public class TezTask extends Task<TezWork> {
         }
 
         // Log all the info required to find the various logs for this query
+        String dagId = this.dagClient.getDagIdentifierString();
         LOG.info("HS2 Host: [{}], Query ID: [{}], Dag ID: [{}], DAG Session ID: [{}]", ServerUtils.hostname(), queryId,
-            this.dagClient.getDagIdentifierString(), this.dagClient.getSessionIdentifierString());
+            dagId, this.dagClient.getSessionIdentifierString());
+        LogUtils.putToMDC(LogUtils.DAGID_KEY, dagId);
 
         // finally monitor will print progress until the job is done
         TezJobMonitor monitor = new TezJobMonitor(work.getAllWork(), dagClient, conf, dag, ctx, counters);