You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/05/01 16:07:06 UTC
[19/23] couch-replicator commit: updated
refs/heads/1843-feature-bigcouch to 4965655
Merge remote-tracking branch 'origin/import-master' into 1843-feature-bigcouch
Conflicts:
Makefile.am
src/couch_replicator_api_wrap.erl
src/couch_replicator_manager.erl
src/couch_replicator_utils.erl
test/04-replication-large-atts.t
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/afb00a35
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/afb00a35
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/afb00a35
Branch: refs/heads/1843-feature-bigcouch
Commit: afb00a35cdafa6f6bed08ecaf8a9e15aa2ddf8b0
Parents: 2db29cc 0ebc319
Author: Robert Newson <rn...@apache.org>
Authored: Tue Apr 29 14:43:34 2014 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Apr 29 14:43:34 2014 +0100
----------------------------------------------------------------------
src/couch_replicator_api_wrap.erl | 77 ++++++++++++++++++++++++++--------
src/couch_replicator_httpd.erl | 2 +-
src/couch_replicator_manager.erl | 3 ++
3 files changed, 64 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/afb00a35/src/couch_replicator_api_wrap.erl
----------------------------------------------------------------------
diff --cc src/couch_replicator_api_wrap.erl
index 821a8dc,3cf942d..ad75c91
--- a/src/couch_replicator_api_wrap.erl
+++ b/src/couch_replicator_api_wrap.erl
@@@ -240,8 -240,8 +240,8 @@@ open_doc_revs(#httpdb{} = HttpDb, Id, R
),
#httpdb{retries = Retries, wait = Wait0} = HttpDb,
Wait = 2 * erlang:min(Wait0 * 2, ?MAX_WAIT),
- couch_log:notice("Retrying GET to ~s in ~p seconds due to error ~s",
- [Url, Wait / 1000, Else]
- ?LOG_INFO("Retrying GET to ~s in ~p seconds due to error ~p",
++ couch_log:notice("Retrying GET to ~s in ~p seconds due to error ~p",
+ [Url, Wait / 1000, error_reason(Else)]
),
ok = timer:sleep(Wait),
RetryDb = HttpDb#httpdb{
@@@ -297,10 -305,14 +305,14 @@@ update_doc(#httpdb{} = HttpDb, #doc{id
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 ->
+ fun(Code, _, {Props}) when Code =:= 200 orelse Code =:= 201 orelse Code =:= 202 ->
{ok, couch_doc:parse_rev(get_value(<<"rev">>, Props))};
(409, _, _) ->
throw(conflict);
@@@ -590,8 -602,8 +602,8 @@@ receive_docs(Streamer, UserFun, Ref, Us
ContentType,
fun() -> receive_doc_data(Streamer, Ref) end,
Ref) of
- {ok, Doc, Parser} ->
+ {ok, Doc, WaitFun, Parser} ->
- case UserFun({ok, Doc}, UserAcc) of
+ case run_user_fun(UserFun, {ok, Doc}, UserAcc, Ref) of
{ok, UserAcc2} ->
ok;
{skip, UserAcc2} ->
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/afb00a35/src/couch_replicator_httpd.erl
----------------------------------------------------------------------
diff --cc src/couch_replicator_httpd.erl
index f84152c,c0fe004..6b43472
--- a/src/couch_replicator_httpd.erl
+++ b/src/couch_replicator_httpd.erl
@@@ -31,10 -31,11 +31,10 @@@ handle_req(#httpd{method = 'POST', user
couch_httpd:validate_ctype(Req, "application/json"),
RepDoc = {Props} = couch_httpd:json_body_obj(Req),
validate_rep_props(Props),
- {ok, Rep} = couch_replicator_utils:parse_rep_doc(RepDoc, UserCtx),
- case couch_replicator:replicate(Rep) of
+ case couch_replicator:replicate(RepDoc, UserCtx) of
{error, {Error, Reason}} ->
send_json(
- Req, 404,
+ Req, 500,
{[{error, to_binary(Error)}, {reason, to_binary(Reason)}]});
{error, not_found} ->
% Tried to cancel a replication that didn't exist.
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/afb00a35/src/couch_replicator_manager.erl
----------------------------------------------------------------------