Skip to content

Commit 1fe05d5

Browse files
committed
[fix] [cli] Fix Broker crashed by too much memory usage of pulsar tools (#20031)
### Motivation After #15868, we allow `PULSAR_MEM` & `PULSAR_GC` to be overridden in `pulsar_tool_env.sh`. Many users set `-Xms` to `2G` or larger in `PULSAR_MEM`, this will make the tools(such as `pulsar-admin`) cost a lot of memory, and if users execute `pulsar-admin` or another tool on the machine where the Broker is deployed, the current device will not have enough memory to allocate, resulting in a broker crash. ### Modifications When `PULSAR_MEM` is overridden in `pulsar_tool_env.sh`, delete parameter `-Xms` (cherry picked from commit 4f503fd)
1 parent 4b9befa commit 1fe05d5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

conf/pulsar_tools_env.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@
4242
# PULSAR_GLOBAL_ZK_CONF=
4343

4444
# Extra options to be passed to the jvm
45+
# Discard parameter "-Xms" of $PULSAR_MEM, which tends to be the Broker's minimum memory, to avoid using too much
46+
# memory by tools.
47+
if [ -n "$PULSAR_MEM" ]; then
48+
PULSAR_MEM_ARR=("${PULSAR_MEM}")
49+
PULSAR_MEM_REWRITE=""
50+
for i in ${PULSAR_MEM_ARR}
51+
do
52+
if [ "${i:0:4}" != "-Xms" ]; then
53+
PULSAR_MEM_REWRITE="$PULSAR_MEM_REWRITE $i";
54+
fi
55+
done
56+
PULSAR_MEM=${PULSAR_MEM_REWRITE}
57+
fi
4558
PULSAR_MEM=${PULSAR_MEM:-"-Xmx128m -XX:MaxDirectMemorySize=128m"}
4659

4760
# Garbage collection options

0 commit comments

Comments
 (0)