couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1126147 - /couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl
Date Sun, 22 May 2011 18:06:42 GMT
Author: fdmanana
Date: Sun May 22 18:06:42 2011
New Revision: 1126147

URL: http://svn.apache.org/viewvc?rev=1126147&view=rev
Log:
Replicator: when streaming don't rely on ibrowse's timeouts

For some reason, when under heavy load (many requests and connections
in parallel), ibrowse doesn't send back timeout messages to streamers.

Modified:
    couchdb/trunk/src/couchdb/couch_api_wrap_httpc.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=1126147&r1=1126146&r2=1126147&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl Sun May 22 18:06:42 2011
@@ -216,7 +216,7 @@ error_cause(Cause) ->
     lists:flatten(io_lib:format("~p", [Cause])).
 
 
-stream_data_self(HttpDb, Params, Worker, ReqId, Cb) ->
+stream_data_self(#httpdb{timeout = T} = HttpDb, Params, Worker, ReqId, Cb) ->
     receive
     {ibrowse_async_response, ReqId, {error, Error}} ->
         throw({maybe_retry_req, Error});
@@ -228,6 +228,11 @@ stream_data_self(HttpDb, Params, Worker,
         {Data, fun() -> stream_data_self(HttpDb, Params, Worker, ReqId, Cb) end};
     {ibrowse_async_response_end, ReqId} ->
         {<<>>, fun() -> throw({maybe_retry_req, more_data_expected}) end}
+    after T + 500 ->
+        % Note: ibrowse should always reply with timeouts, but this doesn't
+        % seem to be always true when there's a very high rate of requests
+        % and many open connections.
+        throw({maybe_retry_req, timeout})
     end.
 
 



Mime
View raw message