commit a3a6f17ed1c30fafa1139d6b74e600ec6df15479 Author: Bharath Krishna Date: Mon Apr 9 10:41:39 2018 -0700 HIVE-19133 : HS2 WebUI phase-wise metrics not showing correctly. diff --git ql/src/java/org/apache/hadoop/hive/ql/Driver.java ql/src/java/org/apache/hadoop/hive/ql/Driver.java index 79db006c7411a52845a5c6a9a77ecbb920bfe348..7179d046e9666e0af4288900dd85f0a188256eb7 100644 --- ql/src/java/org/apache/hadoop/hive/ql/Driver.java +++ ql/src/java/org/apache/hadoop/hive/ql/Driver.java @@ -488,8 +488,7 @@ public int compile(String command, boolean resetTaskIds) { // interrupted, it should be set to true if the compile is called within another method like // runInternal, which defers the close to the called in that method. private void compile(String command, boolean resetTaskIds, boolean deferClose) throws CommandProcessorResponse { - PerfLogger perfLogger = SessionState.getPerfLogger(true); - perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.DRIVER_RUN); + PerfLogger perfLogger = SessionState.getPerfLogger(); perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.COMPILE); lDrvState.stateLock.lock(); try { @@ -659,7 +658,7 @@ public void run() { // get the output schema schema = getSchema(sem, conf); - plan = new QueryPlan(queryStr, sem, perfLogger.getStartTime(PerfLogger.DRIVER_RUN), queryId, + plan = new QueryPlan(queryStr, sem, queryDisplay.getQueryStartTime(), queryId, queryState.getHiveOperation(), schema); @@ -1637,7 +1636,8 @@ private void compileInternal(String command, boolean deferClose) throws CommandP metrics.incrementCounter(MetricsConstant.WAITING_COMPILE_OPS, 1); } - PerfLogger perfLogger = SessionState.getPerfLogger(); + PerfLogger perfLogger = SessionState.getPerfLogger(true); + perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.DRIVER_RUN); perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.WAIT_COMPILE); final ReentrantLock compileLock = tryAcquireCompileLock(isParallelEnabled, command); @@ -1663,7 +1663,7 @@ private void compileInternal(String command, boolean deferClose) throws CommandP } finally { compileLock.unlock(); } - + perfLogger.PerfLogEnd(CLASS_NAME, PerfLogger.DRIVER_RUN); //Save compile-time PerfLogging for WebUI. //Execution-time Perf logs are done by either another thread's PerfLogger //or a reset PerfLogger. @@ -1771,19 +1771,20 @@ private void runInternal(String command, boolean alreadyCompiled) throws Command throw createProcessorResponse(12); } - PerfLogger perfLogger = null; - if (!alreadyCompiled) { // compile internal will automatically reset the perf logger compileInternal(command, true); - // then we continue to use this perf logger - perfLogger = SessionState.getPerfLogger(); } else { - // reuse existing perf logger. - perfLogger = SessionState.getPerfLogger(); // Since we're reusing the compiled plan, we need to update its start time for current run - plan.setQueryStartTime(perfLogger.getStartTime(PerfLogger.DRIVER_RUN)); + plan.setQueryStartTime(queryDisplay.getQueryStartTime()); } + + //Reset the PerfLogger so that it doesn't retain any previous values. + // Any value from compilation phase can be obtained through the map set in queryDisplay during compilation. + PerfLogger perfLogger = SessionState.getPerfLogger(true); + + perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.DRIVER_RUN); + // the reason that we set the txn manager for the cxt here is because each // query has its own ctx object. The txn mgr is shared across the // same instance of Driver, which can run multiple queries.