Github user eiri commented on a diff in the pull request:

    https://github.com/apache/couchdb-fabric/pull/61#discussion_r70134251
  
    --- Diff: src/fabric_group_info.erl ---
    @@ -58,17 +58,23 @@ handle_message({rexi_EXIT, Reason}, Shard, {Counters, 
Acc, Ushards}) ->
         end;
     
     handle_message({ok, Info}, Shard, {Counters0, Acc, Ushards}) ->
    -    NewAcc = append_result(Info, Shard, Acc, Ushards),
    -    Counters1 = fabric_dict:store(Shard, ok, Counters0),
    -    Counters = fabric_view:remove_overlapping_shards(Shard, Counters1),
    -    case is_complete(Counters) of
    -    false ->
    -        {ok, {Counters, NewAcc, Ushards}};
    -    true ->
    -        Pending = aggregate_pending(NewAcc),
    -        Infos = get_infos(NewAcc),
    -        Results = [{updates_pending, {Pending}} | merge_results(Infos)],
    -        {stop, Results}
    +    case fabric_dict:lookup_element(Shard, Counters0) of
    +    undefined ->
    +        % already heard from other node in this range
    --- End diff --
    
    You are missing `remove_overlapping_shards` bit here. It finds overlapping 
shards, sends their rexi workers a kill signal and then removes them from 
Counters dict.
    
    So we can have either element with a key `Shard` and value `nil` (we 
haven't heard from that range from any of the nodes yet) or no element (and 
hence `undefined`), because we already got a response from concurrent shard on 
a different node, updated it with `ok` and then removed _this_ Shard from 
Counters. This answers your next question, why we match on `nil` and not on 
`ok`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to