You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2020/07/24 14:25:51 UTC
[couchdb] branch prototype/fdb-layer-ebtree-spurious-conflicts
created (now b178ed3)
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a change to branch prototype/fdb-layer-ebtree-spurious-conflicts
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
at b178ed3 Only call erlfdb:set if the node changes
This branch includes the following new commits:
new b178ed3 Only call erlfdb:set if the node changes
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb] 01/01: Only call erlfdb:set if the node changes
Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch prototype/fdb-layer-ebtree-spurious-conflicts
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit b178ed32b82897c5dba2d85a4caf03abc5a6f6d8
Author: Robert Newson <rn...@apache.org>
AuthorDate: Fri Jul 24 15:24:40 2020 +0100
Only call erlfdb:set if the node changes
This removes spurious conflicts and allows concurrent writing to
non-overlapping parts of the tree.
---
src/ebtree/src/ebtree.erl | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/ebtree/src/ebtree.erl b/src/ebtree/src/ebtree.erl
index cb5e805..593edf0 100644
--- a/src/ebtree/src/ebtree.erl
+++ b/src/ebtree/src/ebtree.erl
@@ -534,7 +534,7 @@ insert_nonfull(Tx, #tree{} = Tree, #node{level = 0} = Node0, Key, Value) ->
Node1 = Node0#node{
members = umerge(Tree, [{Key, Value}], Node0#node.members)
},
- set_node(Tx, Tree, Node1),
+ set_node(Tx, Tree, Node0, Node1),
reduce_node(Tree, Node1);
insert_nonfull(Tx, #tree{} = Tree, #node{} = Node0, Key, Value) ->
@@ -563,7 +563,7 @@ insert_nonfull(Tx, #tree{} = Tree, #node{} = Node0, Key, Value) ->
members = lists:keyreplace(ChildId1, 3, Node1#node.members,
{NewFirstKey, NewLastKey, ChildId1, NewReduction})
},
- set_node(Tx, Tree, Node2),
+ set_node(Tx, Tree, Node0, Node2),
reduce_node(Tree, Node2).
@@ -584,7 +584,7 @@ delete(Db, #tree{} = Tree, Key) ->
clear_node(Tx, Tree, Root2),
set_node(Tx, Tree, Root2#node{id = ?NODE_ROOT_ID});
Root1 ->
- set_node(Tx, Tree, Root1)
+ set_node(Tx, Tree, Root0, Root1)
end
end),
Tree.
@@ -633,7 +633,7 @@ delete(Tx, #tree{} = Tree, #node{} = Parent0, Key) ->
set_nodes(Tx, Tree, NewNodes),
Parent1;
false ->
- set_node(Tx, Tree, Child1),
+ set_node(Tx, Tree, Child0, Child1),
{_OldFirstKey, _OldLastKey, ChildId0, _OldReduction} = lists:keyfind(ChildId0, 3, Parent0#node.members),
Parent0#node{
members = lists:keyreplace(ChildId0, 3, Parent0#node.members,
@@ -756,6 +756,13 @@ set_nodes(Tx, #tree{} = Tree, Nodes) ->
end, Nodes).
+set_node(_Tx, #tree{} = _Tree, #node{} = Same, #node{} = Same) ->
+ ok;
+
+set_node(Tx, #tree{} = Tree, #node{} = _Different, #node{} = Node) ->
+ set_node(Tx, Tree, Node).
+
+
set_node(Tx, #tree{} = Tree, #node{} = Node) ->
validate_node(Tree, Node),
Key = node_key(Tree#tree.prefix, Node#node.id),