fix(mnesia): apply dump_log_write_threshold before mnesia start.
CI / test (push) Successful in 16m25s
CI / deploy-ift (push) Successful in 5m49s
CI / e2e-ift (push) Failing after 4m38s
CI / deploy-stage (push) Has been skipped
CI / e2e-stage (push) Has been skipped

change_config rejected the key; set_env + verify enables the IFT ceiling ladder. Refs EventHub/EventHubBack#30 Refs EventHub/EventHubBack#34

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-16 19:22:32 +03:00
parent 6dc06ccdf4
commit 4327de486f
7 changed files with 371 additions and 29 deletions
+20 -5
View File
@@ -8,7 +8,7 @@
-export([start_link/0, init_tables/0, wait_for_tables/0, wait_for_table/1]).
-export([add_cluster_nodes/1]).
-export([configure_dump_log/0]).
-export([configure_dump_log/0, verify_dump_log/0]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
@@ -48,16 +48,31 @@ add_cluster_nodes(Nodes) ->
%% @doc Soften dump_log overload under write-heavy load (IFT stress).
%% OTP warns {dump_log, write_threshold|time_threshold} when a new dump
%% is requested while the previous dump still runs.
%% Must be set BEFORE mnesia starts — change_config/2 does not accept
%% dump_log_write_threshold (returns {error, dump_log_write_threshold}).
%% Override: MNESIA_DUMP_LOG_WRITE_THRESHOLD (default 50000; OTP default ~1000).
-spec configure_dump_log() -> ok.
configure_dump_log() ->
Threshold = env_int("MNESIA_DUMP_LOG_WRITE_THRESHOLD", 50000),
case mnesia:change_config(dump_log_write_threshold, Threshold) of
{ok, Old} ->
io:format("Mnesia dump_log_write_threshold: ~p -> ~p~n", [Old, Threshold]),
case application:load(mnesia) of
ok -> ok;
{error, {already_loaded, mnesia}} -> ok;
{error, LoadErr} ->
io:format("Mnesia load before dump_log config failed: ~p~n", [LoadErr])
end,
ok = application:set_env(mnesia, dump_log_write_threshold, Threshold),
io:format("Mnesia dump_log_write_threshold set to ~p (before start)~n", [Threshold]),
ok.
%% @doc Log active threshold after mnesia:start (sanity check for IFT logs).
-spec verify_dump_log() -> ok.
verify_dump_log() ->
case catch mnesia:system_info(dump_log_write_threshold) of
N when is_integer(N) ->
io:format("Mnesia dump_log_write_threshold active: ~p~n", [N]),
ok;
Other ->
io:format("Mnesia dump_log_write_threshold change failed: ~p~n", [Other]),
io:format("Mnesia dump_log_write_threshold verify: ~p~n", [Other]),
ok
end.