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

    https://github.com/apache/couchdb-fabric/pull/61#discussion_r70139806
  
    --- 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 --
    
    It can for the shards we haven't received a response yet.
    
    It goes like this - we are initiating `Counters` dict with all the shards 
as keys and values as `nil`. Shard is a combination of range and node, so even 
though they are all unique, ranges (and accordingly their view_info) are not. 
We are doing this because we can't guess which node with a given range will 
respond first or respond at all. 
    
    Now, once we are starting to receive responses, we are updating our 
`Counters0` dict with `ok` for the received range+node, with gives as 
`Counters1`, and then removing all the duplicated ranges for the rest of the 
nodes, which gives as `Counters`.
    
    Once our `Counters` dict doesn't have any `nil` left (`is_complete/1` is a 
check for that) we know that we've received the responses for all the ranges 
and aggregating info we've kept on `NewAcc ` into final response.



---
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