You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2011/05/22 20:06:42 UTC

svn commit: r1126147 - /couchdb/trunk/src/couchdb/couch_api_wrap_httpc.erl

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.