Skip to content

Commit d284eaf

Browse files
committed
Fix stop_child when Khepri is enabled
It is assumed that old child id format cannot exist in this case.
1 parent 926a875 commit d284eaf

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

deps/rabbitmq_shovel/src/rabbit_shovel_dyn_worker_sup_sup.erl

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,18 @@ stop_child({VHost, ShovelName} = Name) ->
7474
case get({shovel_worker_autodelete, Name}) of
7575
true -> ok; %% [1]
7676
_ ->
77-
case mirrored_supervisor:terminate_child(?SUPERVISOR, id(Name)) of
77+
case stop_and_delete_child(id(Name)) of
7878
ok ->
79-
ok = mirrored_supervisor:delete_child(?SUPERVISOR, id(Name));
79+
ok;
8080
{error, not_found} ->
81-
%% try older format, pre 3.13.0 and 3.12.8. See rabbitmq/rabbitmq-server#9894.
82-
case mirrored_supervisor:terminate_child(?SUPERVISOR, old_id(Name)) of
83-
ok ->
84-
ok = mirrored_supervisor:delete_child(?SUPERVISOR, old_id(Name));
85-
{error, not_found} ->
81+
case rabbit_khepri:is_enabled() of
82+
true ->
83+
%% Old id format is not supported by and cannot exist in Khepri
84+
ok;
85+
false ->
86+
%% try older format, pre 3.13.0 and 3.12.8.
87+
%% See rabbitmq/rabbitmq-server#9894.
88+
_ = stop_and_delete_child(old_id(Name)),
8689
ok
8790
end
8891
end,
@@ -91,6 +94,14 @@ stop_child({VHost, ShovelName} = Name) ->
9194
rabbit_shovel_locks:unlock(LockId),
9295
ok.
9396

97+
stop_and_delete_child(Id) ->
98+
case mirrored_supervisor:terminate_child(?SUPERVISOR, Id) of
99+
ok ->
100+
ok = mirrored_supervisor:delete_child(?SUPERVISOR, Id);
101+
{error, not_found} = Error ->
102+
Error
103+
end.
104+
94105
%% [1] An autodeleting worker removes its own parameter, and thus ends
95106
%% up here via the parameter callback. It is a transient worker that
96107
%% is just about to terminate normally - so we don't need to tell the

0 commit comments

Comments
 (0)