summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@apache.org>2017-07-28 04:52:12 +0000
committerNick Vatamaniuc <nickva@users.noreply.github.com>2017-07-28 14:11:49 -0400
commit058e674bd202cfc8ddbb981c48060fd8bc5c2001 (patch)
tree2033d026568b136de30eb864b70e9d777227206e
parent19bd99ab80abd658bb9848b35c7e6025c0d6fbad (diff)
downloadcouchdb-058e674bd202cfc8ddbb981c48060fd8bc5c2001.tar.gz
Do not unconditioanlly retry a request which was closed unexpectedly
In some case such as when replicator flushes a document received from an open_revs response, it explictly sets the number of retries to 0 because the context for that request might not be restartable and the retry should happen at a higher level. Issue #574
-rw-r--r--src/couch_replicator/src/couch_replicator_httpc.erl6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/couch_replicator/src/couch_replicator_httpc.erl b/src/couch_replicator/src/couch_replicator_httpc.erl
index 58fb0e178..d3c6b0179 100644
--- a/src/couch_replicator/src/couch_replicator_httpc.erl
+++ b/src/couch_replicator/src/couch_replicator_httpc.erl
@@ -128,8 +128,10 @@ stop_and_release_worker(Pool, Worker) ->
end,
ok = couch_replicator_httpc_pool:release_worker_sync(Pool, Worker).
-process_response({error, sel_conn_closed}, _Worker, HttpDb, Params, _Cb) ->
- throw({retry, HttpDb, Params});
+process_response({error, sel_conn_closed}, Worker, HttpDb, Params, _Cb) ->
+ stop_and_release_worker(HttpDb#httpdb.httpc_pool, Worker),
+ maybe_retry(sel_conn_closed, Worker, HttpDb, Params);
+
%% This clause handles un-expected connection closing during pipelined requests.
%% For example, if server responds to a request, sets Connection: close header