diff options
| author | Michael Davis <mcarsondavis@gmail.com> | 2023-03-28 10:46:23 -0500 |
|---|---|---|
| committer | Diana Parra Corbacho <dparracorbac@vmware.com> | 2023-05-12 11:31:16 +0200 |
| commit | 1e7623af26ccfc2a7f55951b8f6f2ce5541fa829 (patch) | |
| tree | 2a7dd1727989b57b250ab9bbd72922ec1ee9019d | |
| parent | 1ec9b281687831d5340e798c7d0ed2290f7e06ad (diff) | |
| download | rabbitmq-server-git-1e7623af26ccfc2a7f55951b8f6f2ce5541fa829.tar.gz | |
Allow duplicate updates in topic graph projection
Previously, the projection function errored from a bad match if a
topic binding was deleted multiple times. Changes to register path
patterns for a projection may be considered multiple times in the case
of a recursive deleted of a subtree. This change removes the hard
match and only cleans up any remaining edges for duplicate deletion
changes.
| -rw-r--r-- | deps/rabbit/src/rabbit_khepri.erl | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/deps/rabbit/src/rabbit_khepri.erl b/deps/rabbit/src/rabbit_khepri.erl index 443081a0a1..93f12d9834 100644 --- a/deps/rabbit/src/rabbit_khepri.erl +++ b/deps/rabbit/src/rabbit_khepri.erl @@ -1011,17 +1011,20 @@ register_rabbit_topic_graph_projection() -> (Table, Path, #{data := OldBindings}, _NewProps) -> [#topic_trie_edge{trie_edge = BindingTrieEdge} = BindingEdge | RestEdges] = edges_for_path(Path, OldBindings), - [#topic_trie_edge{node_id = {bindings, Bindings}}] = - ets:lookup(Table, BindingTrieEdge), - Bindings1 = sets:subtract(Bindings, OldBindings), - case sets:is_empty(Bindings1) of - true -> - ets:delete_object(Table, BindingEdge), - trim_while_out_degree_is_zero(RestEdges); - false -> - ToNodeId = {bindings, Bindings1}, - BindingEdge1 = BindingEdge#topic_trie_edge{node_id = ToNodeId}, - ets:insert(Table, BindingEdge1) + case ets:lookup(Table, BindingTrieEdge) of + [#topic_trie_edge{node_id = {bindings, Bindings}}] -> + Bindings1 = sets:subtract(Bindings, OldBindings), + case sets:is_empty(Bindings1) of + true -> + ets:delete_object(Table, BindingEdge), + trim_while_out_degree_is_zero(RestEdges); + false -> + ToNodeId = {bindings, Bindings1}, + BindingEdge1 = BindingEdge#topic_trie_edge{node_id = ToNodeId}, + ets:insert(Table, BindingEdge1) + end; + [] -> + trim_while_out_degree_is_zero(RestEdges) end; (_Table, _Path, _OldProps, _NewProps) -> ok |
