Skip to content

Commit

Permalink
Merge pull request #452 from rabbitmq/md/ra_lib-sync_file-open-with-read
Browse files Browse the repository at this point in the history
Add `read` to `file:open/2` options in `ra_lib:sync_file/1`
  • Loading branch information
kjnilsson authored Jul 2, 2024
2 parents e51ca80 + f6c61e4 commit 2becc7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ra_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ write_file(Name, IOData, Sync) ->
-spec sync_file(file:name_all()) ->
ok | file_err().
sync_file(Name) ->
case file:open(Name, [binary, write, raw]) of
case file:open(Name, [binary, read, write, raw]) of
{ok, Fd} ->
sync_and_close_fd(Fd);
Err ->
Expand Down
10 changes: 10 additions & 0 deletions test/coordination_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,16 @@ recover_from_checkpoint(Config) ->
Follower2Idx =:= 8
end, 20),

%% Restart the servers: the servers should be able to recover from the
%% snapshot which was promoted from a checkpoint.
[ok = ra:stop_server(?SYS, ServerId) || ServerId <- ServerIds],
[ok = ra:restart_server(?SYS, ServerId) || ServerId <- ServerIds],
[{ok, {_CurrentIdx, _CheckpointIdx = 8}, _Leader} =
ra:local_query(ServerId, fun(State) ->
maps:get(checkpoint_index, State,
undefined)
end) || ServerId <- ServerIds],

stop_nodes(ServerIds),
ok.

Expand Down

0 comments on commit 2becc7b

Please sign in to comment.