Commits

justin  committed 7f34e20

on vnode errors, stop at basic quorum instead of always waiting for N-R+1

  • Participants
  • Parent commits c3b9e81

Comments (0)

Files changed (1)

File apps/riak/src/riak_get_fsm.erl

                                    replied_notfound=Replied0}) ->
     Replied = [Idx|Replied0],
     NewStateData = StateData#state{replied_notfound=Replied},
-    case (N - length(Replied) - length(Fails)) >= R of
+    FailThreshold = erlang:min(trunc((N/2.0)+1), % basic quorum, or
+                               (N-R+1)), % cannot ever get R 'ok' replies
+    case (length(Replied) + length(Fails)) >= FailThreshold of
+        false ->
+            {next_state,waiting_vnode_r,NewStateData};
         true ->
-            {next_state,waiting_vnode_r,NewStateData};
-        false ->
             update_stats(StateData),
             riak_eventer:notify(riak_get_fsm, get_fsm_reply,
                                 {ReqId, notfound}),
                                    replied_notfound=NotFound}) ->
     Replied = [{Err,Idx}|Replied0],
     NewStateData = StateData#state{replied_fail=Replied},
-    case (N - length(Replied) - length(NotFound)) >= R of
+    FailThreshold = erlang:min(trunc((N/2.0)+1), % basic quorum, or
+                               (N-R+1)), % cannot ever get R 'ok' replies
+    case (length(Replied) + length(NotFound)) >= FailThreshold of
+        false ->
+            {next_state,waiting_vnode_r,NewStateData};
         true ->
-            {next_state,waiting_vnode_r,NewStateData};
-        false ->
             case length(NotFound) of
                 0 ->
                     FullErr = [E || {E,_I} <- Replied],