Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D358111BF9 for ; Thu, 28 Aug 2014 12:20:36 +0000 (UTC) Received: (qmail 28045 invoked by uid 500); 28 Aug 2014 12:20:36 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 27977 invoked by uid 500); 28 Aug 2014 12:20:36 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 27959 invoked by uid 99); 28 Aug 2014 12:20:36 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Aug 2014 12:20:36 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 4CFC4A02D21; Thu, 28 Aug 2014 12:20:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Date: Thu, 28 Aug 2014 12:20:36 -0000 Message-Id: <5384cbf1693f42f3b80f6314b8f731e0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/50] fabric commit: updated refs/heads/master to a71701c Repository: couchdb-fabric Updated Branches: refs/heads/master 7dd9dd769 -> a71701c91 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/ec26cbab Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/ec26cbab Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/ec26cbab Branch: refs/heads/master Commit: ec26cbabe767f95f1e67a5c0eb7ab11c7ce18206 Parents: a505676 Author: Robert Newson Authored: Mon Oct 21 18:05:11 2013 +0100 Committer: Robert Newson Committed: Fri Aug 1 15:33:41 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/ec26cbab/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/ec26cbab/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/ec26cbab/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.