This is an automated email from the ASF dual-hosted git repository. dengzh 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 91cab2c635b HIVE-27139: Log the details when hiveserver2.sh doing sanity check with the process id (#4116) (Zhihua Deng, reviewed by Sai Hemanth Gantasala) 91cab2c635b is described below commit 91cab2c635b853c499d98720a7443c549835162a Author: dengzh <dengzhhu...@gmail.com> AuthorDate: Wed Apr 12 10:16:59 2023 +0800 HIVE-27139: Log the details when hiveserver2.sh doing sanity check with the process id (#4116) (Zhihua Deng, reviewed by Sai Hemanth Gantasala) --- bin/ext/hiveserver2.sh | 3 ++- .../src/java/org/apache/hive/service/server/HiveServer2.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/ext/hiveserver2.sh b/bin/ext/hiveserver2.sh index ea95565c4eb..53b429cf9bd 100644 --- a/bin/ext/hiveserver2.sh +++ b/bin/ext/hiveserver2.sh @@ -28,6 +28,7 @@ before_start() { if [ -f $HIVESERVER2_PID ]; then if kill -0 $(cat $HIVESERVER2_PID) >/dev/null 2>&1; then echo "HiveServer2 running as process $(cat $HIVESERVER2_PID). Stop it first." + ps $(cat $HIVESERVER2_PID) exit 1 fi fi @@ -54,7 +55,7 @@ hiveserver2() { commands=$(exec $HADOOP jar $JAR $CLASS -H | grep -v '-hiveconf' | awk '{print $1}') start_hiveserver2='Y' for i in "$@"; do - if [ $(echo "${commands[@]}" | grep -we "$i") != "" ]; then + if [ "$(echo "${commands[@]}" | grep -we $i)" != "" ]; then start_hiveserver2='N' break 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 1409594d12d..5dde31e4020 100644 --- a/service/src/java/org/apache/hive/service/server/HiveServer2.java +++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -19,6 +19,8 @@ package org.apache.hive.service.server; import com.google.common.base.Joiner; + +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -40,6 +42,7 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.curator.framework.CuratorFramework; @@ -923,6 +926,13 @@ public class HiveServer2 extends CompositeService { LOG.error("Error removing znode for this HiveServer2 instance from ZooKeeper.", e); } } + String pidDir = StringUtils.defaultIfEmpty(System.getenv("HIVESERVER2_PID_DIR"), + System.getenv("HIVE_CONF_DIR")); + if (StringUtils.isNotEmpty(pidDir)) { + File pidFile = new File(pidDir, "hiveserver2.pid"); + LOG.info("Deleting the tmp HiveServer2 pid file: {}", pidFile); + FileUtils.deleteQuietly(pidFile); + } super.decommission(); }