couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [09/50] mem3 commit: updated refs/heads/master to 64c0c74
Date Thu, 28 Aug 2014 12:22:29 GMT
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/master
Commit: 68ca9cdfb3c1e9631d2469b5038cec9356e56659
Parents: 8f9f58f
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Thu May 23 10:32:58 2013 -0400
Committer: Robert Newson <rnewson@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) ->


Mime
View raw message