couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject chttpd commit: updated refs/heads/master to 64235ef
Date Thu, 03 Nov 2016 14:43:05 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 21a59b4d8 -> 64235ef3b


handle timeout in _revs_diff

when fabric workers timeout,
fabric:get_missing_revs returns {error,timeout}
this handles timeout errors

COUCHDB-3220


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

Branch: refs/heads/master
Commit: 64235ef3b40be067d8304ee97e23eae0b446337c
Parents: 21a59b4
Author: Mayya Sharipova <mayyas@ca.ibm.com>
Authored: Wed Nov 2 12:40:48 2016 -0400
Committer: Mayya Sharipova <mayyas@ca.ibm.com>
Committed: Wed Nov 2 15:29:02 2016 -0400

----------------------------------------------------------------------
 src/chttpd_db.erl | 45 +++++++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/64235ef3/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index 442ed0c..09a1680 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -532,11 +532,16 @@ db_req(#httpd{path_parts=[_,OP]}=Req, _Db) when ?IS_ALL_DOCS(OP) ->
 db_req(#httpd{method='POST',path_parts=[_,<<"_missing_revs">>]}=Req, Db) ->
     chttpd:validate_ctype(Req, "application/json"),
     {JsonDocIdRevs} = chttpd:json_body_obj(Req),
-    {ok, Results} = fabric:get_missing_revs(Db, JsonDocIdRevs),
-    Results2 = [{Id, couch_doc:revs_to_strs(Revs)} || {Id, Revs, _} <- Results],
-    send_json(Req, {[
-        {missing_revs, {Results2}}
-    ]});
+    case fabric:get_missing_revs(Db, JsonDocIdRevs) of
+        {error, Reason} ->
+            chttpd:send_error(Req, Reason);
+        {ok, Results} ->
+            Results2 = [{Id, couch_doc:revs_to_strs(Revs)} ||
+                    {Id, Revs, _} <- Results],
+            send_json(Req, {[
+                {missing_revs, {Results2}}
+            ]})
+    end;
 
 db_req(#httpd{path_parts=[_,<<"_missing_revs">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "POST");
@@ -544,19 +549,23 @@ db_req(#httpd{path_parts=[_,<<"_missing_revs">>]}=Req, _Db)
->
 db_req(#httpd{method='POST',path_parts=[_,<<"_revs_diff">>]}=Req, Db) ->
     chttpd:validate_ctype(Req, "application/json"),
     {JsonDocIdRevs} = chttpd:json_body_obj(Req),
-    {ok, Results} = fabric:get_missing_revs(Db, JsonDocIdRevs),
-    Results2 =
-    lists:map(fun({Id, MissingRevs, PossibleAncestors}) ->
-        {Id,
-            {[{missing, couch_doc:revs_to_strs(MissingRevs)}] ++
-                if PossibleAncestors == [] ->
-                    [];
-                true ->
-                    [{possible_ancestors,
-                        couch_doc:revs_to_strs(PossibleAncestors)}]
-                end}}
-    end, Results),
-    send_json(Req, {Results2});
+    case fabric:get_missing_revs(Db, JsonDocIdRevs) of
+        {error, Reason} ->
+            chttpd:send_error(Req, Reason);
+        {ok, Results} ->
+            Results2 =
+            lists:map(fun({Id, MissingRevs, PossibleAncestors}) ->
+                {Id,
+                    {[{missing, couch_doc:revs_to_strs(MissingRevs)}] ++
+                        if PossibleAncestors == [] ->
+                            [];
+                        true ->
+                            [{possible_ancestors,
+                                couch_doc:revs_to_strs(PossibleAncestors)}]
+                        end}}
+            end, Results),
+            send_json(Req, {Results2})
+    end;
 
 db_req(#httpd{path_parts=[_,<<"_revs_diff">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "POST");


Mime
View raw message