fix(shared): ensure sticky strategy sticks to the first pick

Prior to this fix, the alive pids are never inserted due to a
missing insert when handing remote pids from mnesia event.
This commit is contained in:
Zaiming (Stone) Shi 2022-10-09 20:13:52 +02:00
parent 761283f616
commit 4f8a7349bf
2 changed files with 8 additions and 0 deletions

View File

@ -64,6 +64,13 @@ File format:
This issue only occurs when unsubscribe with the session kept.
Fixed in [#9119](https://github.com/emqx/emqx/pull/9119)
- Fix shared subscription 'sticky' strategy when there is no local subscriptions at all.
Prior to this change, it may take a few rounds to randomly pick group members until a local subscriber
is hit (and then start sticking to it).
After this fix, it will start sticking to whichever randomly picked member even when it is a
subscriber from another node in the cluster.
Fixed in [#9122](https://github.com/emqx/emqx/pull/9122)
## v4.3.20
### Bug fixes

View File

@ -456,6 +456,7 @@ handle_cast(Msg, State) ->
handle_info({mnesia_table_event, {write, NewRecord, _}}, State = #state{pmon = PMon}) ->
#emqx_shared_subscription{subpid = SubPid} = NewRecord,
ok = maybe_insert_alive_tab(SubPid),
{noreply, update_stats(State#state{pmon = emqx_pmon:monitor(SubPid, PMon)})};
%% The subscriber may have subscribed multiple topics, so we need to keep monitoring the PID until