Skip to content

Commit 9251d9e

Browse files
shuwenweiHTHou
authored andcommitted
[to dev/1.3] Modify default heap dump path of datanode (#14061)
1 parent 944d878 commit 9251d9e

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

iotdb-core/datanode/src/assembly/resources/conf/datanode-env.sh

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,48 @@ calculate_memory_sizes()
143143
}
144144

145145

146+
DATANODE_CONF_DIR="`dirname "$0"`"
147+
# find first dir of dn_data_dirs from properties file
148+
get_first_data_dir() {
149+
local config_file="$1"
150+
local data_dir_value=""
151+
152+
data_dir_value=`sed '/^dn_data_dirs=/!d;s/.*=//' ${DATANODE_CONF_DIR}/${config_file} | tail -n 1`
153+
154+
if [ -z "$data_dir_value" ]; then
155+
echo ""
156+
return 0
157+
fi
158+
159+
local first_dir=""
160+
161+
if [[ "$data_dir_value" == *";"* ]]; then
162+
first_dir=$(echo "$data_dir_value" | cut -d';' -f1)
163+
fi
164+
if [[ "$first_dir" == *","* ]]; then
165+
first_dir=$(echo "$first_dir" | cut -d',' -f1)
166+
fi
167+
168+
if [[ "$first_dir" == /* ]]; then
169+
echo "$first_dir"
170+
else
171+
echo "$DATANODE_CONF_DIR/../$first_dir"
172+
fi
173+
}
174+
175+
if [ -f "${DATANODE_CONF_DIR}/iotdb-system.properties" ]; then
176+
heap_dump_dir=$(get_first_data_dir "iotdb-system.properties")
177+
else
178+
heap_dump_dir=$(get_first_data_dir "iotdb-datanode.properties")
179+
fi
180+
181+
if [ -z "$heap_dump_dir" ]; then
182+
heap_dump_dir="$(dirname "$0")/../data/datanode/data/"
183+
fi
184+
if [ ! -d "$heap_dump_dir" ]; then
185+
mkdir -p "$heap_dump_dir"
186+
fi
187+
146188
# find java in JAVA_HOME
147189
if [ -n "$JAVA_HOME" ]; then
148190
for java in "$JAVA_HOME"/bin/amd64/java "$JAVA_HOME"/bin/java; do
@@ -301,7 +343,7 @@ IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -XX:+SafepointTimeout"
301343
# IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -XX:+AlwaysPreTouch"
302344

303345
# if you want to dump the heap memory while OOM happening, you can use the following command, remember to replace /tmp/heapdump.hprof with your own file path and the folder where this file is located needs to be created in advance
304-
# IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/datanode_heapdump.hprof"
346+
# IOTDB_JMX_OPTS="$IOTDB_JMX_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${heap_dump_dir}/datanode_heapdump.hprof"
305347

306348

307349
echo "DataNode on heap memory size = ${ON_HEAP_MEMORY}B, off heap memory size = ${OFF_HEAP_MEMORY}B"

0 commit comments

Comments
 (0)