diff options
| author | Daniil Fedotov <hairyhum@gmail.com> | 2018-09-27 10:17:09 +0100 |
|---|---|---|
| committer | Daniil Fedotov <hairyhum@gmail.com> | 2018-09-28 11:25:03 +0100 |
| commit | f7e4fa96f200ea98aa3f4c109ebb1584dfe32f5c (patch) | |
| tree | bf3d4f92099429d85e35eac178522609d1c64545 /src | |
| parent | c1fb658ce13ae7f14919bd784eddd3dc77ab5144 (diff) | |
| download | rabbitmq-server-git-f7e4fa96f200ea98aa3f4c109ebb1584dfe32f5c.tar.gz | |
Use delete instead of delete_object and read instead of match_object in bindings where possible.
Route table key contains all the route information, which makes delete
equivalent to delete_object. But it's faster.
For the same reason match_object with a full object is equivalent to read.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_binding.erl | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl index f2bcd93b74..e108640710 100644 --- a/src/rabbit_binding.erl +++ b/src/rabbit_binding.erl @@ -145,7 +145,7 @@ recover_semi_durable_route(Gatherer, R = #route{binding = B}, ToRecover) -> recover_semi_durable_route_txn(R = #route{binding = B}, X) -> rabbit_misc:execute_mnesia_transaction( fun () -> - case mnesia:match_object(rabbit_semi_durable_route, R, read) of + case mnesia:read(rabbit_semi_durable_route, B, read) of [] -> no_recover; _ -> ok = sync_transient_route(R, fun mnesia:write/3), rabbit_exchange:serial(X) @@ -232,7 +232,7 @@ remove(Src, Dst, B, ActingUser) -> lock_resource(Src), lock_resource(Dst), ok = sync_route(#route{binding = B}, durable(Src), durable(Dst), - fun mnesia:delete_object/3), + fun delete/3), Deletions = maybe_auto_delete( B#binding.source, [B], new_deletions(), false), process_deletions(Deletions, ActingUser). @@ -406,21 +406,33 @@ remove_routes(Routes) -> %% This partitioning allows us to suppress unnecessary delete %% operations on disk tables, which require an fsync. {RamRoutes, DiskRoutes} = - lists:partition(fun (R) -> mnesia:match_object( - rabbit_durable_route, R, read) == [] end, + lists:partition(fun (R) -> mnesia:read( + rabbit_durable_route, R#route.binding, read) == [] end, Routes), + {RamOnlyRoutes, SemiDurableRoutes} = + lists:partition(fun (R) -> mnesia:read( + rabbit_semi_durable_route, R#route.binding, read) == [] end, + RamRoutes), %% 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 mnesia:delete_object/3) || - R <- RamRoutes], - [ok = sync_route(R, true, true, fun mnesia:delete_object/3) || + [ok = sync_route(R, true, true, fun delete/3) || R <- DiskRoutes], + [ok = sync_route(R, false, true, fun delete/3) || + R <- SemiDurableRoutes], + [ok = sync_route(R, false, false, fun delete/3) || + R <- RamOnlyRoutes], [R#route.binding || R <- Routes]. + +delete(Tab, #route{binding = B}, LockKind) -> + mnesia:delete(Tab, B, LockKind); +delete(Tab, #reverse_route{reverse_binding = B}, LockKind) -> + mnesia:delete(Tab, B, LockKind). + remove_transient_routes(Routes) -> [begin - ok = sync_transient_route(R, fun mnesia:delete_object/3), + ok = sync_transient_route(R, fun delete/3), R#route.binding end || R <- Routes]. |
