From 97c5f0f3f4a4093d9ddb530db668f94b39bc4280 Mon Sep 17 00:00:00 2001 From: AnmolSun <124231245+AnmolSun@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:15:45 +0530 Subject: [PATCH 1/3] HIVE-28235 : Hive should honour heapsize set in hive-env --- bin/hive | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bin/hive b/bin/hive index fcd33c92cbca..8b95f47b5572 100755 --- a/bin/hive +++ b/bin/hive @@ -380,6 +380,26 @@ if [[ "$SERVICE" =~ ^(hiveserver2|beeline|cli)$ ]] ; then fi fi +# set heap size of hive processes based on HADOOP_HEAPSIZE +if [[ -n "${HADOOP_HEAPSIZE_MAX}" ]]; then + if [[ "${HADOOP_HEAPSIZE_MAX}" =~ ^[0-9]+$ ]]; then + HADOOP_HEAPSIZE_MAX="${HADOOP_HEAPSIZE_MAX}m" + fi + export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xmx${HADOOP_HEAPSIZE_MAX}m " +elif [[ -n "${HADOOP_HEAPSIZE}" ]]; then + if [[ "${HADOOP_HEAPSIZE}" =~ ^[0-9]+$ ]]; then + HADOOP_HEAPSIZE="${HADOOP_HEAPSIZE}m" + fi + export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xmx${HADOOP_HEAPSIZE}m " +fi + +if [[ -n "${HADOOP_HEAPSIZE_MIN}" ]]; then + if [[ "${HADOOP_HEAPSIZE_MIN}" =~ ^[0-9]+$ ]]; then + HADOOP_HEAPSIZE_MIN="${HADOOP_HEAPSIZE_MIN}m" + fi + export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xms${HADOOP_HEAPSIZE_MIN}m " +fi + export JVM_PID="$$" if [ "$TORUN" = "" ] ; then From e179b6f7db02cd3e79793a8b5e3d17887075a460 Mon Sep 17 00:00:00 2001 From: AnmolSun <124231245+AnmolSun@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:28:42 +0530 Subject: [PATCH 2/3] Refactor changes --- bin/hive | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bin/hive b/bin/hive index 8b95f47b5572..22af518e4ebd 100755 --- a/bin/hive +++ b/bin/hive @@ -383,21 +383,18 @@ fi # set heap size of hive processes based on HADOOP_HEAPSIZE if [[ -n "${HADOOP_HEAPSIZE_MAX}" ]]; then if [[ "${HADOOP_HEAPSIZE_MAX}" =~ ^[0-9]+$ ]]; then - HADOOP_HEAPSIZE_MAX="${HADOOP_HEAPSIZE_MAX}m" + export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xmx${HADOOP_HEAPSIZE_MAX}m " fi - export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xmx${HADOOP_HEAPSIZE_MAX}m " elif [[ -n "${HADOOP_HEAPSIZE}" ]]; then if [[ "${HADOOP_HEAPSIZE}" =~ ^[0-9]+$ ]]; then - HADOOP_HEAPSIZE="${HADOOP_HEAPSIZE}m" + export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xmx${HADOOP_HEAPSIZE}m " fi - export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xmx${HADOOP_HEAPSIZE}m " fi if [[ -n "${HADOOP_HEAPSIZE_MIN}" ]]; then if [[ "${HADOOP_HEAPSIZE_MIN}" =~ ^[0-9]+$ ]]; then - HADOOP_HEAPSIZE_MIN="${HADOOP_HEAPSIZE_MIN}m" + export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xms${HADOOP_HEAPSIZE_MIN}m " fi - export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xms${HADOOP_HEAPSIZE_MIN}m " fi export JVM_PID="$$" From e39e366e27dc11ec96ee23b89da8e31955e1dd4a Mon Sep 17 00:00:00 2001 From: AnmolSun <124231245+AnmolSun@users.noreply.github.com> Date: Tue, 30 Apr 2024 20:02:01 +0530 Subject: [PATCH 3/3] Minor change --- bin/hive | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/hive b/bin/hive index 22af518e4ebd..b8d10120a7d8 100755 --- a/bin/hive +++ b/bin/hive @@ -380,7 +380,7 @@ if [[ "$SERVICE" =~ ^(hiveserver2|beeline|cli)$ ]] ; then fi fi -# set heap size of hive processes based on HADOOP_HEAPSIZE +# set heap size of hive processes based on HADOOP_HEAPSIZE env variables if [[ -n "${HADOOP_HEAPSIZE_MAX}" ]]; then if [[ "${HADOOP_HEAPSIZE_MAX}" =~ ^[0-9]+$ ]]; then export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Xmx${HADOOP_HEAPSIZE_MAX}m "