couchdb-commits mailing list archives

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


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

Branch: refs/heads/windsor-merge-121
Commit: 518f76d1e2d1051982220528a113c0007ad17816
Parents: ae1c64a
Author: Benjamin Anderson <b@banjiewen.net>
Authored: Thu Jun 20 15:13:00 2013 -0700
Committer: Robert Newson <rnewson@apache.org>
Committed: Thu Jul 31 10:49:10 2014 +0100

----------------------------------------------------------------------
 src/fabric_util.erl | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/518f76d1/src/fabric_util.erl
----------------------------------------------------------------------
diff --git a/src/fabric_util.erl b/src/fabric_util.erl
index 52055e9..c93efda 100644
--- a/src/fabric_util.erl
+++ b/src/fabric_util.erl
@@ -64,20 +64,21 @@ get_db(DbName, Options) ->
     % suppress shards from down nodes
     Nodes = [node()|erlang:nodes()],
     Live = [S || #shard{node = N} = S <- Shards, lists:member(N, Nodes)],
-    get_shard(Live, Options, 100).
+    Factor = list_to_integer(config:get("fabric", "shard_timeout_factor", "2")),
+    get_shard(Live, Options, 100, Factor).
 
-get_shard([], _Opts, _Timeout) ->
+get_shard([], _Opts, _Timeout, _Factor) ->
     erlang:error({internal_server_error, "No DB shards could be opened."});
-get_shard([#shard{node = Node, name = Name} | Rest], Opts, Timeout) ->
+get_shard([#shard{node = Node, name = Name} | Rest], Opts, Timeout, Factor) ->
     case rpc:call(Node, couch_db, open, [Name, [{timeout, Timeout} | Opts]]) of
     {ok, Db} ->
         {ok, Db};
     {unauthorized, _} = Error ->
         throw(Error);
     {badrpc, {'EXIT', {timeout, _}}} ->
-        get_shard(Rest, Opts, 2*Timeout);
+        get_shard(Rest, Opts, Factor * Timeout, Factor);
     _Else ->
-        get_shard(Rest, Opts, Timeout)
+        get_shard(Rest, Opts, Timeout, Factor)
     end.
 
 error_info({{<<"reduce_overflow_error">>, _} = Error, _Stack}) ->


Mime
View raw message