From e7d70c142c4bb9fa02e596e939317c0cf37515e0 Mon Sep 17 00:00:00 2001 From: ieQu1 <99872536+ieQu1@users.noreply.github.com> Date: Tue, 24 May 2022 13:03:18 +0200 Subject: [PATCH] fix(emqx_shared_sub): Don't crash on table schema change --- apps/emqx/src/emqx_shared_sub.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/emqx/src/emqx_shared_sub.erl b/apps/emqx/src/emqx_shared_sub.erl index ee45b991d..5539c4427 100644 --- a/apps/emqx/src/emqx_shared_sub.erl +++ b/apps/emqx/src/emqx_shared_sub.erl @@ -354,8 +354,10 @@ handle_cast(Msg, State) -> ?SLOG(error, #{msg => "unexpected_cast", req => Msg}), {noreply, State}. -handle_info({mnesia_table_event, {write, NewRecord, _}}, State = #state{pmon = PMon}) -> - #emqx_shared_subscription{subpid = SubPid} = NewRecord, +handle_info( + {mnesia_table_event, {write, #emqx_shared_subscription{subpid = SubPid}, _}}, + State = #state{pmon = 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 %% it `unsubscribed` the last topic.