You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2017/03/01 16:38:43 UTC

[45/50] fabric commit: updated refs/heads/2971-count-distinct to 5d18415

Return error when workers crash

Currently, when one worker survives in fabric_open_revs, we return that
as the response. However, when all workers crash, we still return
{ok, []}. This changes the response to an error.

COUCHDB-3113


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/dd02a393
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/dd02a393
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/dd02a393

Branch: refs/heads/2971-count-distinct
Commit: dd02a3938f267716e3479b7162e0b0a4f8ba3d51
Parents: f9f5681
Author: Tony Sun <to...@cloudant.com>
Authored: Wed Jan 25 13:47:00 2017 -0800
Committer: Tony Sun <to...@cloudant.com>
Committed: Wed Jan 25 14:12:47 2017 -0800

----------------------------------------------------------------------
 src/fabric_doc_open_revs.erl | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/dd02a393/src/fabric_doc_open_revs.erl
----------------------------------------------------------------------
diff --git a/src/fabric_doc_open_revs.erl b/src/fabric_doc_open_revs.erl
index 5393f92..6c8912b 100644
--- a/src/fabric_doc_open_revs.erl
+++ b/src/fabric_doc_open_revs.erl
@@ -47,6 +47,8 @@ go(DbName, Id, Revs, Options) ->
     },
     RexiMon = fabric_util:create_monitors(Workers),
     try fabric_util:recv(Workers, #shard.ref, fun handle_message/3, State) of
+    {ok, []} ->
+        {error, all_workers_died};
     {ok, Replies} ->
         {ok, Replies};
     {timeout, #state{workers=DefunctWorkers}} ->
@@ -314,6 +316,7 @@ open_doc_revs_test_() ->
             check_not_found_counts_for_descendant(),
             check_worker_error_skipped(),
             check_quorum_only_counts_valid_responses(),
+            check_empty_list_when_no_workers_reply(),
             check_not_found_replies_are_removed_when_doc_found(),
             check_not_found_returned_when_one_of_docs_not_found(),
             check_not_found_returned_when_doc_not_found()
@@ -491,6 +494,20 @@ check_quorum_only_counts_valid_responses() ->
     end).
 
 
+check_empty_list_when_no_workers_reply() ->
+    ?_test(begin
+        S0 = state0(revs(), true),
+        Msg1 = {rexi_EXIT, reason},
+        Msg2 = {rexi_EXIT, reason},
+        Msg3 = {rexi_DOWN, nodedown, {nil, node()}, nil},
+        Expect = {stop, []},
+
+        {ok, S1} = handle_message(Msg1, w1, S0),
+        {ok, S2} = handle_message(Msg2, w2, S1),
+        ?assertEqual(Expect, handle_message(Msg3, w3, S2))
+    end).
+
+
 check_not_found_replies_are_removed_when_doc_found() ->
     ?_test(begin
         Replies = replies_to_dict([foo1(), bar1(), fooNF()]),