Skip to content

Commit 7ba04a6

Browse files
Filter out default exchange bindings that may already be in the database
This avoids duplicates after an existing installation is upgraded. References #1721.
1 parent e01dc98 commit 7ba04a6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/rabbit_binding.erl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,14 @@ list(VHostPath) ->
255255
destination = VHostResource,
256256
_ = '_'},
257257
_ = '_'},
258-
implicit_bindings(VHostPath) ++
259-
[B || #route{binding = B} <- mnesia:dirty_match_object(rabbit_route,
260-
Route)].
258+
%% if there are any default exchange bindings left after an upgrade
259+
%% of a pre-3.8 database, filter them out
260+
AllBindings = [B || #route{binding = B} <- mnesia:dirty_match_object(rabbit_route,
261+
Route)],
262+
Filtered = lists:filter(fun(#binding{source = S}) ->
263+
S =/= ?DEFAULT_EXCHANGE(VHostPath)
264+
end, AllBindings),
265+
implicit_bindings(VHostPath) ++ Filtered.
261266

262267
list_for_source(?DEFAULT_EXCHANGE(VHostPath)) ->
263268
implicit_bindings(VHostPath);

0 commit comments

Comments
 (0)