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 Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0b450507 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0b450507 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0b450507 Branch: refs/heads/1901-atomic-multipart-retries Commit: 0b450507670a4649255c2ac4c41d6aa7ae81e45a Parents: ba4e838 Author: Adam Kocoloski <[email protected]> Authored: Thu Sep 12 17:13:07 2013 -0400 Committer: Adam Kocoloski <[email protected]> Committed: Wed Oct 2 12:11:24 2013 -0400 ---------------------------------------------------------------------- src/couch_replicator/src/couch_replicator_api_wrap.erl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/0b450507/src/couch_replicator/src/couch_replicator_api_wrap.erl ---------------------------------------------------------------------- diff --git a/src/couch_replicator/src/couch_replicator_api_wrap.erl b/src/couch_replicator/src/couch_replicator_api_wrap.erl index d8be12a..fccb759 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 ->
