couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1139865 - in /couchdb/trunk/src/couchdb: couch_api_wrap_httpc.erl couch_replicator.erl
Date Sun, 26 Jun 2011 18:08:36 GMT
Author: fdmanana
Date: Sun Jun 26 18:08:36 2011
New Revision: 1139865

URL: http://svn.apache.org/viewvc?rev=1139865&view=rev
Log:
Replicator: less agressive connection requests

For each worker process there's a missing revs finder process.
Therefore we have to account for it when defining the max number
of parallel requests a worker can do, otherwise the processes
waste too much time waiting for connections to become available.

Modified:
    couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl
    couchdb/trunk/src/couchdb/couch_replicator.erl

Modified: couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl?rev=1139865&r1=1139864&r2=1139865&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl Sun Jun 26 18:08:36 2011
@@ -25,7 +25,6 @@
     get_value/3
 ]).
 
--define(RETRY_LATER_WAIT, 50).
 -define(replace(L, K, V), lists:keystore(K, 1, L, {K, V})).
 
 
@@ -87,18 +86,22 @@ send_ibrowse_req(#httpdb{headers = BaseH
     {Worker, Response}.
 
 
+wait_retry() ->
+    ok = timer:sleep(random:uniform(40) + 10).
+
+
 get_piped_worker(#httpdb{httpc_pool = Pool} = HttpDb) ->
     case couch_httpc_pool:get_piped_worker(Pool) of
     {ok, Worker} ->
         Worker;
     retry_later ->
-        ok = timer:sleep(?RETRY_LATER_WAIT),
+        wait_retry(),
         get_piped_worker(HttpDb)
     end.
 
 
 process_response({error, sel_conn_closed}, _Worker, HttpDb, Params, Callback) ->
-    ok = timer:sleep(?RETRY_LATER_WAIT),
+    wait_retry(),
     send_req(HttpDb, Params, Callback);
 
 process_response({error, {'EXIT', {normal, _}}}, _Worker, HttpDb, Params, Cb) ->

Modified: couchdb/trunk/src/couchdb/couch_replicator.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_replicator.erl?rev=1139865&r1=1139864&r2=1139865&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_replicator.erl (original)
+++ couchdb/trunk/src/couchdb/couch_replicator.erl Sun Jun 26 18:08:36 2011
@@ -247,7 +247,7 @@ do_init(#rep{options = Options, id = {Ba
     MaxHttpConns = get_value(http_connections, Options),
     HttpPipeSize = get_value(http_pipeline_size, Options),
     MaxParallelConns = lists:max(
-        [(MaxHttpConns * HttpPipeSize) div CopiersCount, 1]),
+        [((MaxHttpConns * HttpPipeSize) div CopiersCount) - 1, 1]),
     Workers = lists:map(
         fun(_) ->
             {ok, Pid} = couch_replicator_doc_copier:start_link(



Mime
View raw message