summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Lazu <gerhard@lazu.co.uk>2018-02-22 14:25:37 +0000
committerMichael Klishin <michael@clojurewerkz.org>2018-03-28 00:56:34 +0300
commit88945e3814e43431f0dfebb76398412ec484d765 (patch)
treeacf6c3c55b60c32c94eb1e0223bf2eb25aba370e
parentf2ab0b40f034cda6bca4294735b493f20550b93c (diff)
downloadrabbitmq-server-git-88945e3814e43431f0dfebb76398412ec484d765.tar.gz
Delete bindings from mnesia without full table scan
mnesia:match_object/3 scans the entire table and can take many seconds on a loaded node. This is especially bad when there are many bindings which need to be deleted. If the object is in the table then delete it, otherwise carry on. Prior to this change, it was observed that there is a high % of lock collisions in rabbit_topic_trie_binding table: ``` lock id #tries #collisions collisions [%] time [us] duration [%] histogram [log2(us)] ----- --- ------- ------------ --------------- ---------- ------------- --------------------- db_tab rabbit_topic_trie_binding 258465 13627 5.2723 1389904 0.0370 | ...XXxxXx.......... | ``` mnesia:match_object/3 uses a table index if it exists, but in the case of rabbit_topic_trie_binding, there is no table index, so a full table scan used to be performed. For more context, see #1513 Partner-in-crime: @essen
-rw-r--r--src/rabbit_binding.erl9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl
index e4d9e64d6b..7498d6b765 100644
--- a/src/rabbit_binding.erl
+++ b/src/rabbit_binding.erl
@@ -331,13 +331,8 @@ binding_action(Binding = #binding{source = SrcName,
Fun(Src, Dst, Binding#binding{args = SortedArgs})
end, ErrFun).
-delete_object(Tab, Record, LockKind) ->
- %% this 'guarded' delete prevents unnecessary writes to the mnesia
- %% disk log
- case mnesia:match_object(Tab, Record, LockKind) of
- [] -> ok;
- [_] -> mnesia:delete_object(Tab, Record, LockKind)
- end.
+delete_object(Table, Record, LockKind) ->
+ mnesia:delete_object(Table, Record, LockKind).
sync_route(Route, true, true, Fun) ->
ok = Fun(rabbit_durable_route, Route, write),