Skip to content

Commit

Permalink
Merge pull request #464 from rabbitmq/delete-everything-fix
Browse files Browse the repository at this point in the history
Kill snapshot process before deleting everything
  • Loading branch information
kjnilsson authored Aug 14, 2024
2 parents 4c5b409 + b8c5d3c commit 44aa427
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/ra_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,23 @@ read_config(Dir) ->
ra_lib:consult(ConfigPath).

-spec delete_everything(state()) -> ok.
delete_everything(#?MODULE{cfg = #cfg{directory = Dir}} = Log) ->
delete_everything(#?MODULE{cfg = #cfg{directory = Dir},
snapshot_state = SnapState} = Log) ->
_ = close(Log),
%% if there is a snapshot process pending it could cause the directory
%% deletion to fail, best kill the snapshot process first
case ra_snapshot:pending(SnapState) of
{Pid, _, _} ->
case is_process_alive(Pid) of
true ->
exit(Pid, kill),
ok;
false ->
ok
end;
_ ->
ok
end,
try ra_lib:recursive_delete(Dir) of
ok -> ok
catch
Expand Down

0 comments on commit 44aa427

Please sign in to comment.