Merge pull request #9119 from emqx/1009-fix-sticky-dispatch-should-check-subscription-table
fix(shared): check sticky if sticky pid is still a member
This commit is contained in:
commit
4989e57ebb
|
@ -58,6 +58,12 @@ File format:
|
|||
- For wildcard deliveries, the re-dispatch used the wrong topic (the publishing topic,
|
||||
but not the subscribing topic), caused messages to be lost when dispatching.
|
||||
|
||||
- Fix shared subscription group member unsubscribe issue when 'sticky' strategy is used.
|
||||
Prior to this fix, if a previously picked member unsubscribes from the group (without reconnect)
|
||||
the message is still dispatched to it.
|
||||
This issue only occurs when unsubscribe with the session kept.
|
||||
Fixed in [#9119](https://github.com/emqx/emqx/pull/9119)
|
||||
|
||||
## v4.3.20
|
||||
|
||||
### Bug fixes
|
||||
|
|
|
@ -337,7 +337,8 @@ fetch_sender_ref({Sender, Ref}) -> {Sender, Ref}.
|
|||
|
||||
pick(sticky, ClientId, SourceTopic, Group, Topic, FailedSubs) ->
|
||||
Sub0 = erlang:get({shared_sub_sticky, Group, Topic}),
|
||||
case is_active_sub(Sub0, FailedSubs) of
|
||||
All = subscribers(Group, Topic),
|
||||
case is_active_sub(Sub0, FailedSubs, All) of
|
||||
true ->
|
||||
%% the old subscriber is still alive
|
||||
%% keep using it for sticky strategy
|
||||
|
@ -507,8 +508,10 @@ update_stats(State) ->
|
|||
State.
|
||||
|
||||
%% Return 'true' if the subscriber process is alive AND not in the failed list
|
||||
is_active_sub(Pid, FailedSubs) ->
|
||||
not maps:is_key(Pid, FailedSubs) andalso is_alive_sub(Pid).
|
||||
is_active_sub(Pid, FailedSubs, All) ->
|
||||
lists:member(Pid, All) andalso
|
||||
(not maps:is_key(Pid, FailedSubs)) andalso
|
||||
is_alive_sub(Pid).
|
||||
|
||||
%% erlang:is_process_alive/1 does not work with remote pid.
|
||||
is_alive_sub(Pid) when ?IS_LOCAL_PID(Pid) ->
|
||||
|
|
Loading…
Reference in New Issue