rnewson commented on code in PR #5989:
URL: https://github.com/apache/couchdb/pull/5989#discussion_r3174708088


##########
src/fabric/src/fabric_doc_update.erl:
##########
@@ -296,35 +307,36 @@ check_forbidden_msg(Replies) ->
             end
     end.
 
-update_quorum_met(W, Replies) ->
+update_quorum_met(W, Replies, SWS) ->
     Counters = lists:foldl(
         fun(R, D) -> orddict:update_counter(R, 1, D) end,
         orddict:new(),
         Replies
     ),
-    GoodReplies = lists:filter(fun good_reply/1, Counters),
-    case
-        lists:dropwhile(
-            fun
-                ({conflict, _}) -> false;
-                ({_, Count}) -> Count < W
-            end,
-            GoodReplies
-        )
-    of
+    GoodReplies = lists:filter(fun(C) -> good_reply(C, SWS) end, Counters),
+    case lists:dropwhile(quorum_pred(W, SWS), GoodReplies) of
         [] ->
             false;
         [{FinalReply, _} | _] ->
             {true, FinalReply}
     end.
 
-good_reply({{ok, _}, _}) ->
-    true;
-good_reply({noreply, _}) ->
+% With a conflict in sws we stop the quorum early
+quorum_pred(W, true) ->
+    fun
+        ({conflict, _}) -> false;
+        ({_, Count}) -> Count < W
+    end;
+quorum_pred(W, false) ->
+    fun({_, Count}) -> Count < W end.

Review Comment:
   ```
   quorum_pred(W, SWS) when is_boolean(SWS) ->
       fun
           ({conflict, _}) when SWS -> false;
           ({_, Count}) -> Count < W
       end.
   ```
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to