Skip to content

Commit

Permalink
[fix] [cli] Fix Broker crashed by too much memory usage of pulsar too…
Browse files Browse the repository at this point in the history
…ls (#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)
  • Loading branch information
poorbarcode committed Apr 11, 2023
1 parent 4b9befa commit 1fe05d5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions conf/pulsar_tools_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@
# PULSAR_GLOBAL_ZK_CONF=

# Extra options to be passed to the jvm
# Discard parameter "-Xms" of $PULSAR_MEM, which tends to be the Broker's minimum memory, to avoid using too much
# memory by tools.
if [ -n "$PULSAR_MEM" ]; then
PULSAR_MEM_ARR=("${PULSAR_MEM}")
PULSAR_MEM_REWRITE=""
for i in ${PULSAR_MEM_ARR}
do
if [ "${i:0:4}" != "-Xms" ]; then
PULSAR_MEM_REWRITE="$PULSAR_MEM_REWRITE $i";
fi
done
PULSAR_MEM=${PULSAR_MEM_REWRITE}
fi
PULSAR_MEM=${PULSAR_MEM:-"-Xmx128m -XX:MaxDirectMemorySize=128m"}

# Garbage collection options
Expand Down

0 comments on commit 1fe05d5

Please sign in to comment.