fix(cluster-link): cancel heartbeats on client down
This commit is contained in:
parent
e0604e3af6
commit
ede35df24a
|
@ -457,7 +457,8 @@ handle_client_down(Reason, St = #st{target = TargetCluster, actor = Actor}) ->
|
||||||
%% TODO: syncer may be already down due to one_for_all strategy
|
%% TODO: syncer may be already down due to one_for_all strategy
|
||||||
ok = close_syncer(TargetCluster, Actor),
|
ok = close_syncer(TargetCluster, Actor),
|
||||||
_ = maybe_alarm(Reason, St),
|
_ = maybe_alarm(Reason, St),
|
||||||
process_connect(St#st{client = undefined, error = Reason, status = connecting}).
|
NSt = cancel_heartbeat(St),
|
||||||
|
process_connect(NSt#st{client = undefined, error = Reason, status = connecting}).
|
||||||
|
|
||||||
process_bootstrap(St = #st{bootstrapped = false}, _NeedBootstrap) ->
|
process_bootstrap(St = #st{bootstrapped = false}, _NeedBootstrap) ->
|
||||||
run_bootstrap(St);
|
run_bootstrap(St);
|
||||||
|
@ -478,6 +479,12 @@ schedule_heartbeat(St = #st{heartbeat_timer = undefined}) ->
|
||||||
TRef = erlang:start_timer(Timeout, self(), heartbeat),
|
TRef = erlang:start_timer(Timeout, self(), heartbeat),
|
||||||
St#st{heartbeat_timer = TRef}.
|
St#st{heartbeat_timer = TRef}.
|
||||||
|
|
||||||
|
cancel_heartbeat(St = #st{heartbeat_timer = undefined}) ->
|
||||||
|
St;
|
||||||
|
cancel_heartbeat(St = #st{heartbeat_timer = TRef}) ->
|
||||||
|
ok = emqx_utils:cancel_timer(TRef),
|
||||||
|
St#st{heartbeat_timer = undefined}.
|
||||||
|
|
||||||
%% Bootstrapping.
|
%% Bootstrapping.
|
||||||
%% Responsible for transferring local routing table snapshot to the target
|
%% Responsible for transferring local routing table snapshot to the target
|
||||||
%% cluster. Does so either during the initial startup or when MQTT connection
|
%% cluster. Does so either during the initial startup or when MQTT connection
|
||||||
|
|
Loading…
Reference in New Issue