Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using multi statem call only retry for certain errors. #433

Merged
merged 1 commit into from
Apr 23, 2024
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
11 changes: 9 additions & 2 deletions src/ra_server_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,15 @@ statem_call(ServerId, Msg, Timeout) ->

multi_statem_call([ServerId | ServerIds], Msg, Errs, Timeout) ->
case statem_call(ServerId, Msg, Timeout) of
{Tag, _} = E
when Tag == error orelse Tag == timeout ->
{Tag, Info} = E
when Tag == timeout orelse
(Tag == error andalso
(Info == noproc orelse
Info == nodedown orelse
Info == shutdown orelse
Info == system_not_started)) ->
%% these are the retryable errors, any others we consider
%% genuine errors that a retry will not fix
case ServerIds of
[] ->
{error, {no_more_servers_to_try, [E | Errs]}};
Expand Down
8 changes: 4 additions & 4 deletions test/ra_2_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -629,15 +629,15 @@ add_member_without_quorum(Config) ->
{ok, _, _} = ra:add_member(Leader, ServerId4),
ServerId5 = ?config(server_id5, Config),
%% the previous cluster change could not be applied, so cluster changes are not permitted
{error, cluster_change_not_permitted} = ra:add_member(Leader, ServerId5),
{error, cluster_change_not_permitted} = ra:remove_member(Leader, ServerId1),
{error, cluster_change_not_permitted} = ra:add_member(InitialCluster, ServerId5),
{error, cluster_change_not_permitted} = ra:remove_member(InitialCluster, ServerId1),
%% start one follower
timer:sleep(1000),
ok = ra:restart_server(?SYS, hd(Followers)),
timer:sleep(1000),
ok = enqueue(Leader, msg1),
{error, already_member} = ra:add_member(Leader, ServerId4),
{error, not_member} = ra:remove_member(Leader, ServerId5),
{error, already_member} = ra:add_member(InitialCluster, ServerId4),
{error, not_member} = ra:remove_member(InitialCluster, ServerId5),
%%
% timer:sleep(5000),
ok.
Expand Down
Loading