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 2014/08/01 11:10:56 UTC

[10/48] mem3 commit: updated refs/heads/windsor-merge to ff02b9a

Balance replication ownership across nodes

The previous algorithm was biased towards low-numbered nodes, and in the
case of a 3 node cluster would declare db1 to be the owner of all
replications.  We can do better just by leveraging the existing
ushards code.

There's a possibility to refactor this as a new ushards/2 function if
that's perceived as useful.

BugzID: 19870


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/commit/68ca9cdf
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/tree/68ca9cdf
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/diff/68ca9cdf

Branch: refs/heads/windsor-merge
Commit: 68ca9cdfb3c1e9631d2469b5038cec9356e56659
Parents: 8f9f58f
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Thu May 23 10:32:58 2013 -0400
Committer: Robert Newson <rn...@apache.org>
Committed: Wed Jul 23 18:46:25 2014 +0100

----------------------------------------------------------------------
 src/mem3_util.erl | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/68ca9cdf/src/mem3_util.erl
----------------------------------------------------------------------
diff --git a/src/mem3_util.erl b/src/mem3_util.erl
index a63d9a0..5c8c989 100644
--- a/src/mem3_util.erl
+++ b/src/mem3_util.erl
@@ -225,10 +225,8 @@ ensure_exists(DbName) ->
 
 owner(DbName, DocId) ->
     Shards = mem3:shards(DbName, DocId),
-    Nodes = [node()|nodes()],
-    LiveShards = [S || #shard{node=Node} = S <- Shards, lists:member(Node, Nodes)],
-    [#shard{node=Node}] = lists:usort(fun(#shard{name=A}, #shard{name=B}) ->
-                                              A =< B  end, LiveShards),
+    Ushards = mem3:ushards(DbName),
+    [Node] = [N || #shard{node=N} = S <- Shards, lists:member(S, Ushards)],
     node() =:= Node.
 
 is_deleted(Change) ->