diff --git a/apps/emqx_utils/src/emqx_utils.erl b/apps/emqx_utils/src/emqx_utils.erl index e4f0d91d1..de74d06d6 100644 --- a/apps/emqx_utils/src/emqx_utils.erl +++ b/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 diff --git a/apps/emqx_utils/test/emqx_utils_SUITE.erl b/apps/emqx_utils/test/emqx_utils_SUITE.erl index c124f5384..9887fc41c 100644 --- a/apps/emqx_utils/test/emqx_utils_SUITE.erl +++ b/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())). diff --git a/changes/ce/fix-13422.en.md b/changes/ce/fix-13422.en.md new file mode 100644 index 000000000..78b66c72a --- /dev/null +++ b/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. diff --git a/rel/i18n/emqx_schema.hocon b/rel/i18n/emqx_schema.hocon index cea151a87..e2ec44cc9 100644 --- a/rel/i18n/emqx_schema.hocon +++ b/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"""