fix(cluster_rpc): clean self-data by mria stop callback
This commit is contained in:
parent
8e68af14ef
commit
71d34504bf
|
@ -29,7 +29,7 @@
|
|||
status/0,
|
||||
skip_failed_commit/1,
|
||||
fast_forward_to_commit/2,
|
||||
on_leave/0
|
||||
on_mria_stop/1
|
||||
]).
|
||||
-export([
|
||||
commit/2,
|
||||
|
@ -271,14 +271,18 @@ fast_forward_to_commit(Node, ToTnxId) ->
|
|||
gen_server:call({?MODULE, Node}, {fast_forward_to_commit, ToTnxId}).
|
||||
|
||||
%% It is necessary to clean this node commit record in the cluster
|
||||
on_leave() ->
|
||||
gen_server:call(?MODULE, on_leave).
|
||||
on_mria_stop(leave) ->
|
||||
gen_server:call(?MODULE, on_leave);
|
||||
on_mria_stop(_) ->
|
||||
ok.
|
||||
|
||||
%%%===================================================================
|
||||
%%% gen_server callbacks
|
||||
%%%===================================================================
|
||||
|
||||
%% @private
|
||||
init([Node, RetryMs]) ->
|
||||
mria:register_callback(stop, fun ?MODULE:on_mria_stop/1),
|
||||
{ok, _} = mnesia:subscribe({table, ?CLUSTER_MFA, simple}),
|
||||
State = #{node => Node, retry_interval => RetryMs, is_leaving => false},
|
||||
%% The init transaction ID is set in emqx_conf_app after
|
||||
|
|
|
@ -120,7 +120,6 @@ cluster(["join", SNode]) ->
|
|||
emqx_ctl:print("Failed to join the cluster: ~0p~n", [Error])
|
||||
end;
|
||||
cluster(["leave"]) ->
|
||||
emqx_cluster_rpc:on_leave(),
|
||||
case ekka:leave() of
|
||||
ok ->
|
||||
emqx_ctl:print("Leave the cluster successfully.~n"),
|
||||
|
|
Loading…
Reference in New Issue