anishek commented on a change in pull request #881: HIVE-22733 : After disable 
operation log property in hive, still HS2 saving the operation log
URL: https://github.com/apache/hive/pull/881#discussion_r367281830
 
 

 ##########
 File path: common/src/java/org/apache/hadoop/hive/common/LogUtils.java
 ##########
 @@ -219,18 +219,28 @@ public static String maskIfPassword(String key, String 
value) {
    * Register logging context so that log system can print QueryId, SessionId, 
etc for each message
    */
   public static void registerLoggingContext(Configuration conf) {
-    MDC.put(SESSIONID_LOG_KEY, HiveConf.getVar(conf, 
HiveConf.ConfVars.HIVESESSIONID));
-    MDC.put(QUERYID_LOG_KEY, HiveConf.getVar(conf, 
HiveConf.ConfVars.HIVEQUERYID));
     if (HiveConf.getBoolVar(conf, 
HiveConf.ConfVars.HIVE_SERVER2_LOGGING_OPERATION_ENABLED)) {
+      MDC.put(SESSIONID_LOG_KEY, HiveConf.getVar(conf, 
HiveConf.ConfVars.HIVESESSIONID));
+      MDC.put(QUERYID_LOG_KEY, HiveConf.getVar(conf, 
HiveConf.ConfVars.HIVEQUERYID));
       MDC.put(OPERATIONLOG_LEVEL_KEY, HiveConf.getVar(conf, 
HiveConf.ConfVars.HIVE_SERVER2_LOGGING_OPERATION_LEVEL));
+      l4j.info("Thread context registration is done.");
+    } else {
+      l4j.info("Thread context registration is skipped.");
     }
   }
 
   /**
    * Unregister logging context
    */
   public static void unregisterLoggingContext() {
-    MDC.clear();
+    // 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(OPERATIONLOG_LEVEL_KEY);
+    l4j.info("Unregistered logging context.");
+    if (MDC.get(OPERATIONLOG_LEVEL_KEY) != null) {
 
 Review comment:
   why do we need this check here ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to