Skip to content

Commit

Permalink
[feature](script) Add check_jvm_xmx for start_fe.sh
Browse files Browse the repository at this point in the history
* When -Xmx is configured more than 90% of total physical memory, start_fe.sh
  will not allowed to start, because fe maybe been killed by operating system
  with a high probability.
  • Loading branch information
SWJTU-ZhangLei committed Dec 25, 2023
1 parent 8e47fd2 commit b1a2884
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions bin/start_fe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,24 @@ fi
echo "using java version ${java_version}" >>"${LOG_DIR}/fe.out"
echo "${final_java_opt}" >>"${LOG_DIR}/fe.out"

function check_jvm_xmx() {
local os_type=$(uname -s)
if [[ "${os_type}" == "Linux" ]]; then
local total_mem_byte="$(free -b | grep Mem | awk '{print $2}')"
local jvm_xmx_byte="$(${JAVA} ${final_java_opt} -XX:+PrintFlagsFinal -version 2>&1 | awk '/MaxHeapSize/ {print $4}')"
local total_mem_mb=$(($total_mem_byte / 1024 / 1024))
local ninety_percent_mem_mb=$(($total_mem_byte / 10 * 9 / 1024 / 1024))
local jvm_xmx_mb=$(($jvm_xmx_byte / 1024 / 1024))

if [ ${jvm_xmx_mb} -gt ${ninety_percent_mem_mb} ]; then
echo "java opt -Xmx is more than 90% of total physical memory"
echo "total_mem_mb:${total_mem_mb}MB ninety_percent_mem_mb:${ninety_percent_mem_mb}MB jvm_xmx_mb:${jvm_xmx_mb}MB"
exit 1;
fi
fi
}
check_jvm_xmx

# add libs to CLASSPATH
DORIS_FE_JAR=
for f in "${DORIS_HOME}/lib"/*.jar; do
Expand Down

0 comments on commit b1a2884

Please sign in to comment.