Skip to content

Commit

Permalink
Handle post_init and unknown terminate crash (#404)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Unge <simunge@amazon.com>
  • Loading branch information
SimonUnge and SimonUnge authored Dec 20, 2023
1 parent e56d9da commit a5c3135
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ra_server_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,19 @@ terminate(Reason, StateName,
end,
_ = ets:delete(ra_metrics, MetricsKey),
_ = ets:delete(ra_state, Key),
ok;
%% This occurs if there is a crash in the init callback of the ra_machine,
%% before a state has been built
terminate(Reason, StateName, #{id := Id} = Config) ->
LogId = maps:get(friendly_name, Config,
lists:flatten(io_lib:format("~w", [Id]))),
?DEBUG("~ts: terminating with ~w in state ~w",
[LogId, Reason, StateName]),
ok;
%% Unknown reason for termination
terminate(Reason, StateName, State) ->
?DEBUG("Terminating with ~w in state ~w with state ~w",
[Reason, StateName, State]),
ok.

code_change(_OldVsn, StateName, State, _Extra) ->
Expand Down

0 comments on commit a5c3135

Please sign in to comment.