Skip to content

Commit

Permalink
Rename ?NOPROC_RETRY_INTERVAL to ?TRANSIENT_ERROR_RETRY_INTERVAL
Browse files Browse the repository at this point in the history
[Why]
This constant is used for retries after other errors than `noproc`, for
example `noconnection`.
  • Loading branch information
dumbbell committed Aug 23, 2024
1 parent 2e7f1b8 commit 6f1ca7a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/khepri_cluster.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,8 @@ do_query_members(StoreId, RaServer, QueryType, Timeout) ->
true ->
NewTimeout0 = khepri_utils:end_timeout_window(Timeout, T0),
NewTimeout = khepri_utils:sleep(
?NOPROC_RETRY_INTERVAL, NewTimeout0),
?TRANSIENT_ERROR_RETRY_INTERVAL,
NewTimeout0),
do_query_members(
StoreId, RaServer, QueryType, NewTimeout);
false ->
Expand All @@ -1243,7 +1244,7 @@ do_query_members(StoreId, RaServer, QueryType, Timeout) ->
Reason == shutdown) ->
NewTimeout0 = khepri_utils:end_timeout_window(Timeout, T0),
NewTimeout = khepri_utils:sleep(
?NOPROC_RETRY_INTERVAL, NewTimeout0),
?TRANSIENT_ERROR_RETRY_INTERVAL, NewTimeout0),
do_query_members(
StoreId, RaServer, QueryType, NewTimeout);
{timeout, _} ->
Expand Down
6 changes: 3 additions & 3 deletions src/khepri_cluster.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
-define(DEFAULT_RA_SYSTEM_NAME, khepri).
-define(DEFAULT_STORE_ID, khepri).

%% timer:sleep/1 time used as a retry interval when the local Ra server is
%% unaware of a leader exit.
-define(NOPROC_RETRY_INTERVAL, 200).
%% timer:sleep/1 time used as a retry interval when we get errors such as
%% `noproc' or `noconnection'.
-define(TRANSIENT_ERROR_RETRY_INTERVAL, 200).

-define(IS_TIMEOUT(Timeout), (Timeout =:= infinity orelse
(is_integer(Timeout) andalso Timeout >= 0))).
Expand Down
3 changes: 2 additions & 1 deletion src/khepri_machine.erl
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,8 @@ do_process_sync_command(StoreId, Command, Options) ->
%% Retry again after waiting a bit.
NewTimeout0 = khepri_utils:end_timeout_window(Timeout, T0),
NewTimeout = khepri_utils:sleep(
?NOPROC_RETRY_INTERVAL, NewTimeout0),
?TRANSIENT_ERROR_RETRY_INTERVAL,
NewTimeout0),
Options1 = Options#{timeout => NewTimeout},
do_process_sync_command(StoreId, Command, Options1);
false ->
Expand Down

0 comments on commit 6f1ca7a

Please sign in to comment.