Skip to content

Commit

Permalink
Prevent deadlock with application_controller shutdown by using mnesia…
Browse files Browse the repository at this point in the history
…:system_info(is_running) instead. (#143)
  • Loading branch information
slezakattack authored Aug 22, 2022
1 parent 29d1acf commit 12fedf6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/collectors/mnesia/prometheus_mnesia_collector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ deregister_cleanup(_) -> ok.
_Registry :: prometheus_registry:registry(),
Callback :: prometheus_collector:callback().
collect_mf(_Registry, Callback) ->
case is_started(mnesia) of
case mnesia_running() of
true ->
EnabledMetrics = enabled_metrics(),
Metrics = metrics(EnabledMetrics),
Expand Down Expand Up @@ -181,11 +181,9 @@ catch_all(DataFun) ->
catch _:_ -> undefined
end.

is_started(App) ->
case [V || {A,_,V} <- application:which_applications(), A == App] of
[] -> false;
[_] -> true
end.
mnesia_running() ->
erlang:function_exported(mnesia, system_info, 1) andalso
mnesia:system_info(is_running) == yes.

enabled_metrics() ->
application:get_env(prometheus, mnesia_collector_metrics, all).
Expand Down

0 comments on commit 12fedf6

Please sign in to comment.