@@ -510,7 +510,7 @@ handover_candidates(Server) ->
510
510
511
511
-spec disable (Server :: gen_statem :server_ref (), Reason :: term ()) -> ok | {error , ErrorReason :: atom ()}.
512
512
disable (Server , Reason ) ->
513
- gen_statem :cast (Server , ? DISABLE_COMMAND (Reason )).
513
+ gen_statem :call (Server , ? DISABLE_COMMAND (Reason ), ? RAFT_RPC_CALL_TIMEOUT ( )).
514
514
515
515
-spec enable (Server :: gen_statem :server_ref ()) -> ok | {error , ErrorReason :: atom ()}.
516
516
enable (Server ) ->
@@ -1980,7 +1980,7 @@ command(StateName, {call, From}, ?ENABLE_COMMAND, #raft_state{name = Name, curre
1980
1980
[Name , CurrentTerm , StateName , From ], #{domain => [whatsapp , wa_raft ]}),
1981
1981
{keep_state_and_data , {reply , From , {error , already_enabled }}};
1982
1982
% % [Disable] All nodes should disable by setting RAFT state disable_reason.
1983
- command (StateName , cast , ? DISABLE_COMMAND (Reason ), # raft_state {name = Name , self = ? IDENTITY_REQUIRES_MIGRATION (_ , NodeId ), current_term = CurrentTerm , leader_id = LeaderId } = State0 ) ->
1983
+ command (StateName , { call , From } , ? DISABLE_COMMAND (Reason ), # raft_state {name = Name , self = ? IDENTITY_REQUIRES_MIGRATION (_ , NodeId ), current_term = CurrentTerm , leader_id = LeaderId } = State0 ) ->
1984
1984
? LOG_NOTICE (" Server[~0p , term ~0p , ~0p ] disabling due to reason ~p ." ,
1985
1985
[Name , CurrentTerm , StateName , Reason ], #{domain => [whatsapp , wa_raft ]}),
1986
1986
State1 = State0 # raft_state {disable_reason = Reason },
@@ -1989,7 +1989,7 @@ command(StateName, cast, ?DISABLE_COMMAND(Reason), #raft_state{name = Name, self
1989
1989
false -> State1
1990
1990
end ,
1991
1991
wa_raft_durable_state :store (State2 ),
1992
- {next_state , disabled , State2 };
1992
+ {next_state , disabled , State2 , { reply , From , ok } };
1993
1993
% % [Fallback] Drop unknown command calls.
1994
1994
command (StateName , Type , Event , # raft_state {name = Name , current_term = CurrentTerm }) ->
1995
1995
? LOG_NOTICE (" Server[~0p , term ~0p , ~0p ] dropping unhandled command ~p event ~p " ,
0 commit comments