Skip to content

Commit 28741cd

Browse files
Dynamic Shovels: filter out old supervisor child IDs
So that they do not make it to Khepri.
1 parent 2ce0307 commit 28741cd

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

deps/rabbitmq_shovel/src/rabbit_shovel_dyn_worker_sup_sup.erl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,24 @@ cleanup_specs() ->
9494
ParamsSet = sets:from_list([ {proplists:get_value(vhost, S), proplists:get_value(name, S)}
9595
|| S <- rabbit_runtime_parameters:list_component(<<"shovel">>) ]),
9696
F = fun(Name, ok) ->
97-
_ = mirrored_supervisor:delete_child(?SUPERVISOR, id(Name)),
97+
try
98+
%% The supervisor operation is very unlikely to fail, it's the schema
99+
%% data stores that can make a fuss about a non-existent or non-standard value passed in.
100+
%% For example, an old style Shovel name is an invalid Khepri query path element. MK.
101+
_ = mirrored_supervisor:delete_child(?SUPERVISOR, id(Name))
102+
catch _:_:_Stacktrace ->
103+
ok
104+
end,
98105
ok
99106
end,
100-
AllSpecs = sets:union(NewStyleSpecsSet, OldStyleSpecsSet),
107+
%% Khepri won't handle values in OldStyleSpecsSet in its path well. At the same time,
108+
%% those older elements simply cannot exist in Khepri because having Khepri enabled
109+
%% means a cluster-wide move to 3.13+, so we can conditionally compute what specs we care about. MK.
110+
AllSpecs =
111+
case rabbit_khepri:is_enabled() of
112+
true -> NewStyleSpecsSet;
113+
false -> sets:union(NewStyleSpecsSet, OldStyleSpecsSet)
114+
end,
101115
%% Delete any supervisor children that do not have their respective runtime parameters in the database.
102116
SetToCleanUp = sets:subtract(AllSpecs, ParamsSet),
103117
ok = sets:fold(F, ok, SetToCleanUp).

0 commit comments

Comments
 (0)