fix: subscribe stats_collector after Mnesia tables are ready
Backfill ran during init_tables before wait_for_tables, so dirty reads hit {no_exists,user} and crash-looped eventhub on IFT.
This commit is contained in:
@@ -127,7 +127,18 @@ do_subscribe(State) ->
|
||||
false -> stats_tops:rebuild()
|
||||
end,
|
||||
lists:foreach(fun(Table) ->
|
||||
mnesia:subscribe({table, Table, detailed})
|
||||
case lists:member(Table, mnesia:system_info(tables)) of
|
||||
true ->
|
||||
case mnesia:wait_for_tables([Table], 60000) of
|
||||
ok -> mnesia:subscribe({table, Table, detailed});
|
||||
{timeout, _} ->
|
||||
error_logger:warning_msg(
|
||||
"stats_collector: skip subscribe ~p (wait timeout)~n", [Table])
|
||||
end;
|
||||
false ->
|
||||
error_logger:warning_msg(
|
||||
"stats_collector: skip subscribe ~p (no table)~n", [Table])
|
||||
end
|
||||
end, ?SUB_TABLES),
|
||||
State#state{ready = true, subscribed = true}.
|
||||
|
||||
@@ -371,7 +382,13 @@ backfill_all() ->
|
||||
|
||||
safe_match(Table, Pattern) ->
|
||||
case lists:member(Table, mnesia:system_info(tables)) of
|
||||
true -> mnesia:dirty_match_object(Pattern);
|
||||
true ->
|
||||
try mnesia:dirty_match_object(Pattern) of
|
||||
Rows when is_list(Rows) -> Rows
|
||||
catch
|
||||
exit:{aborted, {no_exists, _}} -> [];
|
||||
error:{aborted, {no_exists, _}} -> []
|
||||
end;
|
||||
false -> []
|
||||
end.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user