Merge pull request #11733 from keynslug/fix/EMQX-10827/sesson-takeover
fix(cm): bring back pre-v5.3.0 compat in `takeover_session_begin/1`
This commit is contained in:
commit
a2e86c67db
|
@ -298,9 +298,9 @@ takeover_session_begin(ClientId) ->
|
||||||
|
|
||||||
takeover_session_begin(ClientId, ChanPid) when is_pid(ChanPid) ->
|
takeover_session_begin(ClientId, ChanPid) when is_pid(ChanPid) ->
|
||||||
case takeover_session(ClientId, ChanPid) of
|
case takeover_session(ClientId, ChanPid) of
|
||||||
{living, ConnMod, Session} ->
|
{living, ConnMod, ChanPid, Session} ->
|
||||||
{ok, Session, {ConnMod, ChanPid}};
|
{ok, Session, {ConnMod, ChanPid}};
|
||||||
none ->
|
_ ->
|
||||||
none
|
none
|
||||||
end;
|
end;
|
||||||
takeover_session_begin(_ClientId, undefined) ->
|
takeover_session_begin(_ClientId, undefined) ->
|
||||||
|
@ -368,13 +368,20 @@ do_takeover_begin(ClientId, ChanPid) when node(ChanPid) == node() ->
|
||||||
ConnMod when is_atom(ConnMod) ->
|
ConnMod when is_atom(ConnMod) ->
|
||||||
case request_stepdown({takeover, 'begin'}, ConnMod, ChanPid) of
|
case request_stepdown({takeover, 'begin'}, ConnMod, ChanPid) of
|
||||||
{ok, Session} ->
|
{ok, Session} ->
|
||||||
{living, ConnMod, Session};
|
{living, ConnMod, ChanPid, Session};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
error(Reason)
|
error(Reason)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
do_takeover_begin(ClientId, ChanPid) ->
|
do_takeover_begin(ClientId, ChanPid) ->
|
||||||
wrap_rpc(emqx_cm_proto_v2:takeover_session(ClientId, ChanPid)).
|
case wrap_rpc(emqx_cm_proto_v2:takeover_session(ClientId, ChanPid)) of
|
||||||
|
%% NOTE: v5.3.0
|
||||||
|
{living, ConnMod, Session} ->
|
||||||
|
{living, ConnMod, ChanPid, Session};
|
||||||
|
%% NOTE: other versions
|
||||||
|
Res ->
|
||||||
|
Res
|
||||||
|
end.
|
||||||
|
|
||||||
%% @doc Discard all the sessions identified by the ClientId.
|
%% @doc Discard all the sessions identified by the ClientId.
|
||||||
-spec discard_session(emqx_types:clientid()) -> ok.
|
-spec discard_session(emqx_types:clientid()) -> ok.
|
||||||
|
|
|
@ -65,8 +65,10 @@ get_chann_conn_mod(ClientId, ChanPid) ->
|
||||||
|
|
||||||
-spec takeover_session(emqx_types:clientid(), emqx_cm:chan_pid()) ->
|
-spec takeover_session(emqx_types:clientid(), emqx_cm:chan_pid()) ->
|
||||||
none
|
none
|
||||||
| {expired | persistent, emqx_session:session()}
|
|
||||||
| {living, _ConnMod :: atom(), emqx_cm:chan_pid(), emqx_session:session()}
|
| {living, _ConnMod :: atom(), emqx_cm:chan_pid(), emqx_session:session()}
|
||||||
|
%% NOTE: v5.3.0
|
||||||
|
| {living, _ConnMod :: atom(), emqx_session:session()}
|
||||||
|
| {expired | persistent, emqx_session:session()}
|
||||||
| {badrpc, _}.
|
| {badrpc, _}.
|
||||||
takeover_session(ClientId, ChanPid) ->
|
takeover_session(ClientId, ChanPid) ->
|
||||||
rpc:call(node(ChanPid), emqx_cm, takeover_session, [ClientId, ChanPid], ?T_TAKEOVER * 2).
|
rpc:call(node(ChanPid), emqx_cm, takeover_session, [ClientId, ChanPid], ?T_TAKEOVER * 2).
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Resolved an incompatibility issue that led to crashes during session takeover / channel eviction when the session was residing on a remote node running EMQX v5.2.x or earlier.
|
Loading…
Reference in New Issue