Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ra_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,8 @@ machine_query(QueryFun, #{cfg := #cfg{effective_machine_module = MacMod},

become(leader, #{cluster := Cluster, log := Log0} = State) ->
Log = ra_log:release_resources(maps:size(Cluster) + 2, random, Log0),
State#{log => Log};
State#{log => Log,
cluster_change_permitted => false};
become(follower, #{log := Log0} = State) ->
%% followers should only ever need a single segment open at any one
%% time
Expand Down
22 changes: 22 additions & 0 deletions test/ra_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ all_tests() ->
local_query_stale,
members,
consistent_query,
consistent_query_after_restart,
consistent_query_minority,
consistent_query_leader_change,
consistent_query_stale,
Expand Down Expand Up @@ -544,6 +545,27 @@ consistent_query(Config) ->
{ok, 14, Leader} = ra:consistent_query(A, fun(S) -> S end),
terminate_cluster(Cluster).

new_value(A, _) ->
A.

consistent_query_after_restart(Config) ->
DataDir = filename:join([?config(priv_dir, Config), "data"]),
[A, B] = Cluster = start_local_cluster(2, ?config(test_name, Config),
{simple, fun ?MODULE:new_value/2, 0}),
%% this test occasionally reproduces a stale read bug after a restart
%% NB: occasionally....
[begin
{ok, _, _} = ra:process_command(A, N, ?PROCESS_COMMAND_TIMEOUT),
application:stop(ra),
restart_ra(DataDir),
ok = ra:restart_server(A),
ok = ra:restart_server(B),
?assertMatch({ok, N, _}, ra:consistent_query(A, fun(S) -> S end))
end || N <- lists:seq(1, 30)],

terminate_cluster(Cluster),
ok.

consistent_query_minority(Config) ->
[A, _, _] = Cluster = start_local_cluster(3, ?config(test_name, Config),
add_machine()),
Expand Down
1 change: 1 addition & 0 deletions test/ra_log_segment_writer_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
%% Copyright (c) 2017-2022 VMware, Inc. or its affiliates. All rights reserved.
%%
-module(ra_log_segment_writer_SUITE).
-compile(nowarn_export_all).
-compile(export_all).

-include_lib("common_test/include/ct.hrl").
Expand Down