fix(emqx_slow_subs): fix upgrade action error

This commit is contained in:
lafirest 2022-02-18 16:27:22 +08:00
parent 513942a2d8
commit 1a1415a996
1 changed files with 10 additions and 6 deletions

View File

@ -192,19 +192,23 @@ code_change({down, _Vsn}, #{config := Cfg} = State, ["4.4.0"]) ->
{ok, State}; {ok, State};
code_change(_OldVsn, #{config := Conf} = State, ["4.4.0"]) -> code_change(_OldVsn, #{config := Conf} = State, ["4.4.0"]) ->
%% clear old data
HookPoint = 'message.slow_subs_stats', HookPoint = 'message.slow_subs_stats',
case emqx_hooks:lookup(HookPoint) of Callbacks = emqx_hooks:lookup(HookPoint),
[Action | _] -> _ = [emqx_hooks:del(HookPoint, Action) ||
emqx_hooks:del(HookPoint, Action); {callback, Action, _Filter, _Priority} <- Callbacks],
_ ->
ok
end,
try try
ets:delete_all_objects(?TOPK_TAB) ets:delete_all_objects(?TOPK_TAB)
catch _:_ -> catch _:_ ->
ok ok
end, end,
%% add new table
init_tab(), init_tab(),
[_Sup, SupPid] = erlang:get('$ancestors'),
ets:give_away(?INDEX_TAB, SupPid, undefined),
%% enable
expire_tick(Conf), expire_tick(Conf),
load(Conf), load(Conf),
{ok, State}; {ok, State};