summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2013-09-12 17:13:07 -0400
committerAdam Kocoloski <adam@cloudant.com>2013-10-02 12:11:24 -0400
commit0b450507670a4649255c2ac4c41d6aa7ae81e45a (patch)
treec5af7ef597ca33b037e529bcb066e184fbcabda6
parentba4e8382a2318ea4aab9174f17a84eb0eb41d605 (diff)
downloadcouchdb-0b450507670a4649255c2ac4c41d6aa7ae81e45a.tar.gz
Disable automatic retries of streaming writes
An automatic retry makes no sense here, as we've already streamed part of the response body from the GET. Disabling the retries bubbles the error up to run_user_fun inside open_doc_revs allows us to retry the whole GET + PUT correctly. BugzID: 20822
-rw-r--r--src/couch_replicator/src/couch_replicator_api_wrap.erl8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/couch_replicator/src/couch_replicator_api_wrap.erl b/src/couch_replicator/src/couch_replicator_api_wrap.erl
index d8be12a25..fccb7595e 100644
--- a/src/couch_replicator/src/couch_replicator_api_wrap.erl
+++ b/src/couch_replicator/src/couch_replicator_api_wrap.erl
@@ -221,7 +221,7 @@ open_doc_revs(#httpdb{} = HttpDb, Id, Revs, Options, Fun, Acc) ->
),
#httpdb{retries = Retries, wait = Wait0} = HttpDb,
Wait = 2 * erlang:min(Wait0 * 2, ?MAX_WAIT),
- twig:log(notice,"Retrying GET to ~s in ~p seconds due to error ~s",
+ twig:log(notice,"Retrying GET to ~s in ~p seconds due to error ~p",
[Url, Wait / 1000, Else]
),
ok = timer:sleep(Wait),
@@ -278,7 +278,11 @@ update_doc(#httpdb{} = HttpDb, #doc{id = DocId} = Doc, Options, Type) ->
end ++ [{"Content-Type", ?b2l(ContentType)}, {"Content-Length", Len}],
Body = {fun stream_doc/1, {JsonBytes, Doc#doc.atts, Boundary, Len}},
send_req(
- HttpDb,
+ % A crash here bubbles all the way back up to run_user_fun inside
+ % open_doc_revs, which will retry the whole thing. That's the
+ % appropriate course of action, since we've already started streaming
+ % the response body from the GET request.
+ HttpDb#httpdb{retries = 0},
[{method, put}, {path, encode_doc_id(DocId)},
{qs, QArgs}, {headers, Headers}, {body, Body}],
fun(Code, _, {Props}) when Code =:= 200 orelse Code =:= 201 ->