refactor(resource-manager-sup): do not force kill resource manager
the shutdown timeout is now set to infinity so it will never force kill a resource manager, otherwise there will be resource leaks
This commit is contained in:
parent
21de0f8274
commit
f5e5c59763
|
@ -133,7 +133,7 @@ ensure_worker_removed(ResId, Idx) ->
|
||||||
ok ->
|
ok ->
|
||||||
_ = supervisor:delete_child(?SERVER, ChildId),
|
_ = supervisor:delete_child(?SERVER, ChildId),
|
||||||
%% no need to remove worker from the pool,
|
%% no need to remove worker from the pool,
|
||||||
%% because the entire pool will be forece deleted later
|
%% because the entire pool will be force deleted later
|
||||||
ok;
|
ok;
|
||||||
{error, not_found} ->
|
{error, not_found} ->
|
||||||
ok
|
ok
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
-behaviour(supervisor).
|
-behaviour(supervisor).
|
||||||
|
|
||||||
-export([ensure_child/5]).
|
-export([ensure_child/5, delete_child/1]).
|
||||||
|
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
|
|
||||||
|
@ -27,6 +27,11 @@ ensure_child(ResId, Group, ResourceType, Config, Opts) ->
|
||||||
_ = supervisor:start_child(?MODULE, [ResId, Group, ResourceType, Config, Opts]),
|
_ = supervisor:start_child(?MODULE, [ResId, Group, ResourceType, Config, Opts]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
delete_child(Pid) ->
|
||||||
|
_ = supervisor:terminate_child(?MODULE, Pid),
|
||||||
|
_ = supervisor:delete_child(?MODULE, Pid),
|
||||||
|
ok.
|
||||||
|
|
||||||
start_link() ->
|
start_link() ->
|
||||||
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
|
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
|
||||||
|
|
||||||
|
@ -36,7 +41,10 @@ init([]) ->
|
||||||
id => emqx_resource_manager,
|
id => emqx_resource_manager,
|
||||||
start => {emqx_resource_manager, start_link, []},
|
start => {emqx_resource_manager, start_link, []},
|
||||||
restart => transient,
|
restart => transient,
|
||||||
shutdown => brutal_kill,
|
%% never force kill a resource manager.
|
||||||
|
%% becasue otherwise it may lead to release leak,
|
||||||
|
%% resource_manager's terminate callback calls resource on_stop
|
||||||
|
shutdown => infinity,
|
||||||
type => worker,
|
type => worker,
|
||||||
modules => [emqx_resource_manager]
|
modules => [emqx_resource_manager]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue