fix(buffer-worker-sup): fast stop

the timeout shutdown in child spec may
significantly slow down the deletion of a resource

this commit chagnes the shutdown to brutal kill

also, the pool worker removal code has been delete
because it's not necessary since the entier pool is
going to be force-delete later anyway
This commit is contained in:
Zaiming (Stone) Shi 2023-05-17 22:42:15 +02:00
parent be90c63c78
commit 21de0f8274
1 changed files with 7 additions and 7 deletions

View File

@ -115,7 +115,8 @@ ensure_worker_started(ResId, Idx, Opts) ->
id => ?CHILD_ID(Mod, ResId, Idx),
start => {Mod, start_link, [ResId, Idx, Opts]},
restart => transient,
shutdown => 5000,
%% if we delay shutdown, when the pool is big, it will take a long time
shutdown => brutal_kill,
type => worker,
modules => [Mod]
},
@ -130,13 +131,12 @@ ensure_worker_removed(ResId, Idx) ->
ChildId = ?CHILD_ID(emqx_resource_buffer_worker, ResId, Idx),
case supervisor:terminate_child(?SERVER, ChildId) of
ok ->
Res = supervisor:delete_child(?SERVER, ChildId),
_ = gproc_pool:remove_worker(ResId, {ResId, Idx}),
Res;
{error, not_found} ->
_ = supervisor:delete_child(?SERVER, ChildId),
%% no need to remove worker from the pool,
%% because the entire pool will be forece deleted later
ok;
{error, Reason} ->
{error, Reason}
{error, not_found} ->
ok
end.
ensure_disk_queue_dir_absent(ResourceId, Index) ->