nickva commented on code in PR #6092:
URL: https://github.com/apache/couchdb/pull/6092#discussion_r3767000956


##########
src/fabric/src/fabric_doc_update.erl:
##########
@@ -321,32 +321,43 @@ check_forbidden_msg(Replies) ->
     end.
 
 update_quorum_met(W, Replies, SWS) ->
+    % With sws=true conflict after the owner returns ok should not turn into a 
conflict
+    % it should be become an accepted (202) instead. But if we don't have any 
ok responses,
+    % say owner returned an error then we should return a conflict from a 
secondary node.
+    ConflictsFinal = SWS andalso not any_ok(Replies),
     Counters = lists:foldl(
         fun(R, D) -> orddict:update_counter(R, 1, D) end,
         orddict:new(),
         Replies
     ),
-    GoodReplies = lists:filter(fun(C) -> good_reply(C, SWS) end, Counters),
-    case lists:dropwhile(quorum_pred(W, SWS), GoodReplies) of
+    GoodReplies = lists:filter(fun(C) -> good_reply(C, ConflictsFinal) end, 
Counters),
+    case lists:dropwhile(quorum_pred(W, ConflictsFinal), GoodReplies) of
         [] ->
             false;
         [{FinalReply, _} | _] ->
             {true, FinalReply}
     end.
 
-% With a conflict in sws we stop the quorum early
-quorum_pred(W, SWS) when is_boolean(SWS) ->
+any_ok(Replies) ->
+    Fun = fun
+        ({ok, _}) -> true;
+        (_) -> false
+    end,
+    lists:any(Fun, Replies).
+
+% Final confluct => stop the quorum early

Review Comment:
   thanks!



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