couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [27/49] fabric commit: updated refs/heads/windsor-merge to b1c0030
Date Fri, 01 Aug 2014 14:34:48 GMT
Report errors opening documents during _all_docs

All errors are currently ignored in the receive statements and
eventually we timeout.  This patch causes fabric to report the error and
terminate quickly instead of waiting.

BugzID: 24580


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

Branch: refs/heads/windsor-merge
Commit: 5e2d376c3ca19f42faeab66aa432f7b3d17955b4
Parents: 8e80f22
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Fri Oct 25 22:59:23 2013 -0400
Committer: Robert Newson <rnewson@apache.org>
Committed: Fri Aug 1 15:33:42 2014 +0100

----------------------------------------------------------------------
 src/fabric_view_all_docs.erl | 39 +++++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/5e2d376c/src/fabric_view_all_docs.erl
----------------------------------------------------------------------
diff --git a/src/fabric_view_all_docs.erl b/src/fabric_view_all_docs.erl
index 28a1f91..cda748a 100644
--- a/src/fabric_view_all_docs.erl
+++ b/src/fabric_view_all_docs.erl
@@ -69,12 +69,17 @@ go(DbName, Options, QueryArgs, Callback, Acc0) ->
         false -> Keys2
     end,
     Timeout = fabric_util:all_docs_timeout(),
-    receive {'DOWN', Ref0, _, _, {ok, TotalRows}} ->
-        {ok, Acc1} = Callback({meta, [{total, TotalRows}]}, Acc0),
-        {ok, Acc2} = doc_receive_loop(
-            Keys3, queue:new(), SpawnFun, MaxJobs, Callback, Acc1
-        ),
-        Callback(complete, Acc2)
+    receive {'DOWN', Ref0, _, _, Result} ->
+        case Result of
+            {ok, TotalRows} ->
+                {ok, Acc1} = Callback({meta, [{total, TotalRows}]}, Acc0),
+                {ok, Acc2} = doc_receive_loop(
+                    Keys3, queue:new(), SpawnFun, MaxJobs, Callback, Acc1
+                ),
+                Callback(complete, Acc2);
+            Error ->
+                Callback({error, Error}, Acc0)
+        end
     after Timeout ->
         Callback(timeout, Acc0)
     end.
@@ -178,15 +183,21 @@ doc_receive_loop(Keys, Pids, SpawnFun, MaxJobs, Callback, AccIn) ->
     _ ->
         {{value, {Pid, Ref}}, RestPids} = queue:out(Pids),
         Timeout = fabric_util:all_docs_timeout(),
-        receive {'DOWN', Ref, process, Pid, #view_row{} = Row} ->
-            case Callback(fabric_view:transform_row(Row), AccIn) of
-            {ok, Acc} ->
-                doc_receive_loop(
-                    Keys, RestPids, SpawnFun, MaxJobs, Callback, Acc
-                );
-            {stop, Acc} ->
+        receive {'DOWN', Ref, process, Pid, Row} ->
+            case Row of
+            #view_row{} ->
+                case Callback(fabric_view:transform_row(Row), AccIn) of
+                {ok, Acc} ->
+                    doc_receive_loop(
+                        Keys, RestPids, SpawnFun, MaxJobs, Callback, Acc
+                    );
+                {stop, Acc} ->
+                    cancel_read_pids(RestPids),
+                    {ok, Acc}
+                end;
+            Error ->
                 cancel_read_pids(RestPids),
-                {ok, Acc}
+                Callback({error, Error}, AccIn)
             end
         after Timeout ->
             timeout


Mime
View raw message