This is an automated email from the ASF dual-hosted git repository.

yubiao pushed a commit to branch branch-2.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.10 by this push:
     new 1fe05d5cd3e [fix] [cli] Fix Broker crashed by too much memory usage of 
pulsar tools (#20031)
1fe05d5cd3e is described below

commit 1fe05d5cd3ec9f70cd7179efa4b69eac72fd88bd
Author: fengyubiao <[email protected]>
AuthorDate: Tue Apr 11 21:47:02 2023 +0800

    [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 4f503fd886cd25670b6344defb8feb1ff2a6e816)
---
 conf/pulsar_tools_env.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/conf/pulsar_tools_env.sh b/conf/pulsar_tools_env.sh
index a356dbb9a28..9d22b73905d 100755
--- a/conf/pulsar_tools_env.sh
+++ b/conf/pulsar_tools_env.sh
@@ -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

Reply via email to