fix(emqx_shared_sub): Don't crash on table schema change

This commit is contained in:
ieQu1 2022-05-24 13:03:18 +02:00
parent 9de609224e
commit e7d70c142c
1 changed files with 4 additions and 2 deletions

View File

@ -354,8 +354,10 @@ handle_cast(Msg, State) ->
?SLOG(error, #{msg => "unexpected_cast", req => Msg}), ?SLOG(error, #{msg => "unexpected_cast", req => Msg}),
{noreply, State}. {noreply, State}.
handle_info({mnesia_table_event, {write, NewRecord, _}}, State = #state{pmon = PMon}) -> handle_info(
#emqx_shared_subscription{subpid = SubPid} = NewRecord, {mnesia_table_event, {write, #emqx_shared_subscription{subpid = SubPid}, _}},
State = #state{pmon = PMon}
) ->
{noreply, update_stats(State#state{pmon = emqx_pmon:monitor(SubPid, PMon)})}; {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 %% The subscriber may have subscribed multiple topics, so we need to keep monitoring the PID until
%% it `unsubscribed` the last topic. %% it `unsubscribed` the last topic.