Skip to content

Commit f0a68ad

Browse files
Merge pull request #1691 from rabbitmq/remove-bindings
Idempotent binding removal
2 parents 25a3fe4 + 98040f6 commit f0a68ad

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/rabbit_binding.erl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,6 @@ binding_action(Binding = #binding{source = SrcName,
343343
Fun(Src, Dst, Binding#binding{args = SortedArgs})
344344
end, ErrFun).
345345

346-
dirty_delete_object(Table, Record, _LockKind) ->
347-
mnesia:dirty_delete_object(Table, Record).
348-
349346
sync_route(Route, true, true, Fun) ->
350347
ok = Fun(rabbit_durable_route, Route, write),
351348
sync_route(Route, false, true, Fun);
@@ -415,15 +412,15 @@ remove_routes(Routes) ->
415412
%% Of course the destination might not really be durable but it's
416413
%% just as easy to try to delete it from the semi-durable table
417414
%% than check first
418-
[ok = sync_route(R, false, true, fun dirty_delete_object/3) ||
415+
[ok = sync_route(R, false, true, fun mnesia:delete_object/3) ||
419416
R <- RamRoutes],
420-
[ok = sync_route(R, true, true, fun dirty_delete_object/3) ||
417+
[ok = sync_route(R, true, true, fun mnesia:delete_object/3) ||
421418
R <- DiskRoutes],
422419
[R#route.binding || R <- Routes].
423420

424421
remove_transient_routes(Routes) ->
425422
[begin
426-
ok = sync_transient_route(R, fun dirty_delete_object/3),
423+
ok = sync_transient_route(R, fun mnesia:delete_object/3),
427424
R#route.binding
428425
end || R <- Routes].
429426

@@ -447,10 +444,7 @@ remove_for_destination(DstName, OnlyDurable, Fun) ->
447444
lists:keysort(#binding.source, Bindings), OnlyDurable).
448445

449446
%% Instead of locking entire table on remove operations we can lock the
450-
%% affected resource only. This will allow us to use dirty_match_object for
451-
%% do faster search of records to delete.
452-
%% This works better when there are multiple resources deleted at once, for
453-
%% example when exclusive queues are deleted.
447+
%% affected resource only.
454448
lock_resource(Name) ->
455449
mnesia:lock({global, Name, mnesia:table_info(rabbit_route, where_to_write)},
456450
write).

0 commit comments

Comments
 (0)