Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
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
  • Loading branch information
kocolosk authored and rnewson committed Jul 23, 2014
1 parent 8f9f58f commit 68ca9cdfb3c1e9631d2469b5038cec9356e56659
Showing 1 changed file with 2 additions and 4 deletions.
@@ -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) ->

0 comments on commit 68ca9cd

Please sign in to comment.