Просмотр исходного кода

Merge pull request #13422 from thalesmg/20240705-r57-max-heap-size-0

fix: handle `max_heap_size` = 0
Thales Macedo Garitezi 1 год назад
Родитель
Сommit
f9b6ae0c1a

+ 3 - 1
apps/emqx_utils/src/emqx_utils.erl

@@ -289,8 +289,10 @@ do_check_oom([{Val, Max, Reason} | Rest]) ->
     end.
 
 tune_heap_size(#{enable := false}) ->
-    ok;
+    ignore;
 %% If the max_heap_size is set to zero, the limit is disabled.
+tune_heap_size(#{max_heap_size := 0}) ->
+    ignore;
 tune_heap_size(#{max_heap_size := MaxHeapSize}) when MaxHeapSize > 0 ->
     MaxSize =
         case erlang:system_info(wordsize) of

+ 16 - 0
apps/emqx_utils/test/emqx_utils_SUITE.erl

@@ -154,6 +154,22 @@ t_check(_) ->
         emqx_utils:check_oom(Policy)
     ).
 
+t_tune_heap_size(_Config) ->
+    Policy = #{
+        max_mailbox_size => 10,
+        max_heap_size => 1024 * 1024 * 8,
+        enable => true
+    },
+    ?assertEqual(ignore, emqx_utils:tune_heap_size(Policy#{enable := false})),
+    %% Setting it to 0 disables the check.
+    ?assertEqual(ignore, emqx_utils:tune_heap_size(Policy#{max_heap_size := 0})),
+    {max_heap_size, PreviousHeapSize} = process_info(self(), max_heap_size),
+    try
+        ?assertMatch(PreviousHeapSize, emqx_utils:tune_heap_size(Policy))
+    after
+        process_flag(max_heap_size, PreviousHeapSize)
+    end.
+
 t_rand_seed(_) ->
     ?assert(is_tuple(emqx_utils:rand_seed())).
 

+ 1 - 0
changes/ce/fix-13422.en.md

@@ -0,0 +1 @@
+Fixed an issue where the option `force_shutdown.max_heap_size` could not be set to 0 to disable this tuning.

+ 1 - 1
rel/i18n/emqx_schema.hocon

@@ -801,7 +801,7 @@ mqtt_max_topic_levels.label:
 """Max Topic Levels"""
 
 force_shutdown_max_heap_size.desc:
-"""Total heap size"""
+"""Total heap size.  Setting this to 0 disables this limitation."""
 
 force_shutdown_max_heap_size.label:
 """Total heap size"""