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

zhangbutao 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 4ada92871a0 HIVE-28983: Log HS2 and HMS PID and update hive-env.sh 
template (#5884)
4ada92871a0 is described below

commit 4ada92871a09f4d14f349105eb9e166ae0c7c0e7
Author: Raghav Aggarwal <raghavaggarwal03...@gmail.com>
AuthorDate: Mon Jul 7 20:14:10 2025 +0530

    HIVE-28983: Log HS2 and HMS PID and update hive-env.sh template (#5884)
---
 conf/hive-env.sh.template                          | 57 ++++++++++++++--------
 .../apache/hive/service/server/HiveServer2.java    |  2 +-
 .../hadoop/hive/metastore/HiveMetaStore.java       |  6 ++-
 3 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/conf/hive-env.sh.template b/conf/hive-env.sh.template
index 72e78d52bdd..c2d86e65893 100644
--- a/conf/hive-env.sh.template
+++ b/conf/hive-env.sh.template
@@ -1,3 +1,5 @@
+#!/usr/bin/env bash
+
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -18,20 +20,31 @@
 # to control the execution of Hive. It should be used by admins to configure
 # the Hive installation (so that users do not have to set environment variables
 # or set command line parameters to get correct behavior).
-#
-# The hive service being invoked (CLI etc.) is available via the environment
-# variable SERVICE
 
+# Set HADOOP_HOME to point to a specific hadoop install directory
+# HADOOP_HOME=${bin}/../../hadoop
+
+# Hive Configuration Directory can be controlled by:
+# export HIVE_CONF_DIR=
+
+# Folder containing extra libraries required for hive compilation/execution 
can be controlled by:
+# export HIVE_AUX_JARS_PATH=
+
+# HIVE Log Directory can be controlled by the following and ensure it exists 
on the filesystem:
+# export HIVE_LOG_DIR=
+
+# The hive service being invoked (beeline etc.) is available via the 
environment
+# variable SERVICE
 
 # Hive Client memory usage can be an issue if a large number of clients
-# are running at the same time. The flags below have been useful in 
+# are running at the same time. The flags below have been useful in
 # reducing memory usage:
-#
-# if [ "$SERVICE" = "cli" ]; then
+
+# if [ "$SERVICE" = "beeline" ]; then
 #   if [ -z "$DEBUG" ]; then
-#     export HADOOP_OPTS="$HADOOP_OPTS -XX:NewRatio=12 -Xms10m 
-XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:+UseParNewGC 
-XX:-UseGCOverheadLimit"
+#     export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xms10m 
-XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:+UseG1GC 
-XX:-UseGCOverheadLimit"
 #   else
-#     export HADOOP_OPTS="$HADOOP_OPTS -XX:NewRatio=12 -Xms10m 
-XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:-UseGCOverheadLimit"
+#     export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xms10m 
-XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:-UseGCOverheadLimit"
 #   fi
 # fi
 
@@ -39,16 +52,22 @@
 #
 # export HADOOP_HEAPSIZE=1024
 #
-# Larger heap size may be required when running queries over large number of 
files or partitions. 
-# By default hive shell scripts use a heap size of 256 (MB).  Larger heap size 
would also be 
+# Larger heap size may be required when running queries over large number of 
files or partitions.
+# By default hive shell scripts use a heap size of 256 (MB).  Larger heap size 
would also be
 # appropriate for hive server.
 
-
-# Set HADOOP_HOME to point to a specific hadoop install directory
-# HADOOP_HOME=${bin}/../../hadoop
-
-# Hive Configuration Directory can be controlled by:
-# export HIVE_CONF_DIR=
-
-# Folder containing extra libraries required for hive compilation/execution 
can be controlled by:
-# export HIVE_AUX_JARS_PATH=
+# if [ "$SERVICE" = "metastore" ]; then
+#   export HADOOP_HEAPSIZE=1024
+#   export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS 
-Dhive.log.dir=$HIVE_LOG_DIR -Dhive.log.file=hive$SERVICE.log \
+#     -Dlog4j.configurationFile=$HIVE_CONF_DIR/hive-log4j2.properties 
-XX:+UseG1GC \
+#     -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$HIVE_LOG_DIR \
+#     
-Xlog:gc*=info:file=$HIVE_LOG_DIR/gc-${SERVICE}-%p-%t.log:time,uptime,level,tags:filecount=5,filesize=16M"
+# fi
+#
+# if [ "$SERVICE" = "hiveserver2" ]; then
+#   export HADOOP_HEAPSIZE=1024
+#   export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS 
-Dhive.log.dir=$HIVE_LOG_DIR \
+#     -Dhive.log.file=$SERVICE.log 
-Dlog4j.configurationFile=$HIVE_CONF_DIR/hive-log4j2.properties \
+#     -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError 
-XX:HeapDumpPath=$HIVE_LOG_DIR \
+#     
-Xlog:gc*=info:file=$HIVE_LOG_DIR/gc-${SERVICE}-%p-%t.log:time,uptime,level,tags:filecount=5,filesize=16M"
+# fi
diff --git a/service/src/java/org/apache/hive/service/server/HiveServer2.java 
b/service/src/java/org/apache/hive/service/server/HiveServer2.java
index db4fda9ee07..990beadc88f 100644
--- a/service/src/java/org/apache/hive/service/server/HiveServer2.java
+++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java
@@ -1207,7 +1207,7 @@ public void startPrivilegeSynchronizer(HiveConf hiveConf) 
throws Exception {
   private static void startHiveServer2() throws Throwable {
     long attempts = 0, maxAttempts = 1;
     while (true) {
-      LOG.info("Starting HiveServer2");
+      LOG.info("Starting HiveServer2. PID is: {}", 
ProcessHandle.current().pid());
       HiveConf hiveConf = new HiveConf();
       maxAttempts = 
hiveConf.getLongVar(HiveConf.ConfVars.HIVE_SERVER2_MAX_START_ATTEMPTS);
       long retrySleepIntervalMs = hiveConf
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 5c51a84f378..23cc6e8420c 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -252,9 +252,11 @@ public static void main(String[] args) throws Throwable {
     startupShutdownMessage(HiveMetaStore.class, args, LOG);
 
     try {
-      String msg = "Starting hive metastore on port " + cli.getPort();
+      String msg =
+          "Starting hive metastore on port %d. PID is %d"
+              .formatted(cli.getPort(), ProcessHandle.current().pid());
       LOG.info(msg);
-      if (cli.isVerbose()) {
+      if (isCliVerbose) {
         System.err.println(msg);
       }
 

Reply via email to