summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Lazu <gerhard@lazu.co.uk>2018-02-22 14:25:37 +0000
committerGerhard Lazu <gerhard@lazu.co.uk>2018-03-27 16:07:35 +0100
commit0752ddb4dc5f78673605616a038057616c08cc6c (patch)
treef76bbf72d33e9b32c628c7493934abffb2e2393f
parent5f7b7cd66b9c0274e7b0b52494f320da7b5798fb (diff)
downloadrabbitmq-server-git-0752ddb4dc5f78673605616a038057616c08cc6c.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),