Oh yeah. I remember fixing that bug, guess I never amended the commit.

On Aug 17, 2013, at 1:03 PM, "Paul J. Davis" <notifications@github.com>
wrote:

In src/mem3_rebalance.erl:

> @@ -23,8 +23,43 @@ rebalance(DbName) ->
>  rebalance(DbName, TargetNodes) when is_binary(DbName) ->
>      rebalance(mem3:shards(DbName), TargetNodes);
>  rebalance(Shards, TargetNodes) when is_list(Shards) ->
> +    %% first migrate shards off of non-target nodes
> +    {OK, MoveThese} = lists:partition(fun(#shard{node=Node}) ->
> +        lists:member(Node, TargetNodes)
> +    end, Shards),
> +    ShardsByTargetNode0 = lists:foldl(fun(Shard, Acc) ->
> +        orddict:append(Shard#shard.node, Shard, Acc)
> +    end, orddict:new(), OK),
> +    ShardsByTargetNode = lists:sort(lists:foldl(fun(Node, Acc) ->
> +        case orddict:is_key(Node, ShardsByTargetNode0) of
> +            true ->
> +                Acc;
> +            false ->
> +                [{Node, []} | Acc]

Shouldn't you be using orddict here? There's no guarantee that TargetNodes
is sorted definitely no guarantee that all TargetNodes sort before whatever
is in ShardsByTargetNode0.

—
Reply to this email directly or view it on
GitHub<https://github.com/cloudant/mem3/pull/57/files#r5829299>
.