couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [45/50] fabric commit: updated refs/heads/windsor-merge-121 to 79e6e2f
Date Fri, 01 Aug 2014 09:12:33 GMT
Make all timeouts configurable

BugzID: 24302


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

Branch: refs/heads/windsor-merge-121
Commit: 209a2004958f93c53b4e19dc356a7d03bed28bdc
Parents: 49dd38c
Author: Robert Newson <robert.newson@cloudant.com>
Authored: Mon Oct 21 18:05:11 2013 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Thu Jul 31 17:22:34 2014 +0100

----------------------------------------------------------------------
 src/fabric_doc_attachments.erl |  6 ++++--
 src/fabric_util.erl            | 13 +++++++++++--
 src/fabric_view_all_docs.erl   |  6 ++++--
 3 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/209a2004/src/fabric_doc_attachments.erl
----------------------------------------------------------------------
diff --git a/src/fabric_doc_attachments.erl b/src/fabric_doc_attachments.erl
index af56137..a703db9 100644
--- a/src/fabric_doc_attachments.erl
+++ b/src/fabric_doc_attachments.erl
@@ -34,11 +34,12 @@ receiver(Req, Length) when is_integer(Length) ->
     Middleman = spawn(fun() -> middleman(Req, Length) end),
     fun() ->
         Middleman ! {self(), gimme_data},
+        Timeout = fabric_util:attachments_timeout(),
         receive
             {Middleman, Data} ->
                 rexi:reply(attachment_chunk_received),
                 iolist_to_binary(Data)
-        after 600000 ->
+        after Timeout ->
             exit(timeout)
         end
     end;
@@ -64,6 +65,7 @@ maybe_send_continue(#httpd{mochi_req = MochiReq} = Req) ->
 
 write_chunks(MiddleMan, ChunkFun) ->
     MiddleMan ! {self(), gimme_data},
+    Timeout = fabric_util:attachments_timeout(),
     receive
     {MiddleMan, ChunkRecordList} ->
         rexi:reply(attachment_chunk_received),
@@ -71,7 +73,7 @@ write_chunks(MiddleMan, ChunkFun) ->
         continue -> write_chunks(MiddleMan, ChunkFun);
         done -> ok
         end
-    after 600000 ->
+    after Timeout ->
         exit(timeout)
     end.
 

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/209a2004/src/fabric_util.erl
----------------------------------------------------------------------
diff --git a/src/fabric_util.erl b/src/fabric_util.erl
index fb6cd8b..344ead7 100644
--- a/src/fabric_util.erl
+++ b/src/fabric_util.erl
@@ -15,7 +15,7 @@
 -export([submit_jobs/3, submit_jobs/4, cleanup/1, recv/4, get_db/1, get_db/2, error_info/1,
         update_counter/3, remove_ancestors/2, create_monitors/1, kv/2,
         remove_down_workers/2]).
--export([request_timeout/0]).
+-export([request_timeout/0, attachments_timeout/0, all_docs_timeout/0]).
 -export([stream_start/2, stream_start/4]).
 
 -include_lib("fabric/include/fabric.hrl").
@@ -138,7 +138,16 @@ recv(Workers, Keypos, Fun, Acc0) ->
     rexi_utils:recv(Workers, Keypos, Fun, Acc0, request_timeout(), infinity).
 
 request_timeout() ->
-    case config:get("fabric", "request_timeout", "60000") of
+    timeout("request", "60000").
+
+all_docs_timeout() ->
+    timeout("all_docs", "10000").
+
+attachments_timeout() ->
+    timeout("attachments", "600000").
+
+timeout(Type, Default) ->
+    case config:get("fabric", Type ++ "_timeout", Default) of
         "infinity" -> infinity;
         N -> list_to_integer(N)
     end.

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/209a2004/src/fabric_view_all_docs.erl
----------------------------------------------------------------------
diff --git a/src/fabric_view_all_docs.erl b/src/fabric_view_all_docs.erl
index 8dc9173..28a1f91 100644
--- a/src/fabric_view_all_docs.erl
+++ b/src/fabric_view_all_docs.erl
@@ -68,13 +68,14 @@ go(DbName, Options, QueryArgs, Callback, Acc0) ->
         true -> lists:sublist(Keys2, Limit);
         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)
-    after 10000 ->
+    after Timeout ->
         Callback(timeout, Acc0)
     end.
 
@@ -176,6 +177,7 @@ doc_receive_loop(Keys, Pids, SpawnFun, MaxJobs, Callback, AccIn) ->
         doc_receive_loop(RKeys, Pids1, 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} ->
@@ -186,7 +188,7 @@ doc_receive_loop(Keys, Pids, SpawnFun, MaxJobs, Callback, AccIn) ->
                 cancel_read_pids(RestPids),
                 {ok, Acc}
             end
-        after 10000 ->
+        after Timeout ->
             timeout
         end
     end.


Mime
View raw message