Skip to content

Idempotent binding removal #1691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/rabbit_binding.erl
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,6 @@ binding_action(Binding = #binding{source = SrcName,
Fun(Src, Dst, Binding#binding{args = SortedArgs})
end, ErrFun).

dirty_delete_object(Table, Record, _LockKind) ->
mnesia:dirty_delete_object(Table, Record).

sync_route(Route, true, true, Fun) ->
ok = Fun(rabbit_durable_route, Route, write),
sync_route(Route, false, true, Fun);
Expand Down Expand Up @@ -415,15 +412,15 @@ remove_routes(Routes) ->
%% Of course the destination might not really be durable but it's
%% just as easy to try to delete it from the semi-durable table
%% than check first
[ok = sync_route(R, false, true, fun dirty_delete_object/3) ||
[ok = sync_route(R, false, true, fun mnesia:delete_object/3) ||
R <- RamRoutes],
[ok = sync_route(R, true, true, fun dirty_delete_object/3) ||
[ok = sync_route(R, true, true, fun mnesia:delete_object/3) ||
R <- DiskRoutes],
[R#route.binding || R <- Routes].

remove_transient_routes(Routes) ->
[begin
ok = sync_transient_route(R, fun dirty_delete_object/3),
ok = sync_transient_route(R, fun mnesia:delete_object/3),
R#route.binding
end || R <- Routes].

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

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