You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2014/08/28 19:30:26 UTC
[26/50] [abbrv] couch-replicator commit: updated
refs/heads/1963-eunit-bigcouch to 3cf0b13
Retry if doc is missing
The catch-all clause in remote_doc_handler is the root cause of
missing updates in replication. This occurs when we receive a
{{not_found,missing}, Rev} message instead of the expected {ok, Doc}
message, and causes us to continue blindly on, including writing a
checkpoint.
This patch changes the catch-all clause to one that handles the
missing doc case and causes a retry. Any other response will be a
function_clause which will cause a messier retry.
BugzID: 31722
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/75e5ba17
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/75e5ba17
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/75e5ba17
Branch: refs/heads/1963-eunit-bigcouch
Commit: 75e5ba177431483522f983ffab305213f0ccbfe6
Parents: 22e9ff4
Author: Robert Newson <rn...@apache.org>
Authored: Thu Jun 19 14:36:32 2014 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Thu Jul 31 11:57:31 2014 +0100
----------------------------------------------------------------------
src/couch_replicator_api_wrap.erl | 2 ++
src/couch_replicator_worker.erl | 9 +++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/75e5ba17/src/couch_replicator_api_wrap.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_api_wrap.erl b/src/couch_replicator_api_wrap.erl
index c6fe691..fbbff19 100644
--- a/src/couch_replicator_api_wrap.erl
+++ b/src/couch_replicator_api_wrap.erl
@@ -262,6 +262,8 @@ open_doc_revs(#httpdb{} = HttpDb, Id, Revs, Options, Fun, Acc) ->
receive
{'DOWN', Ref, process, Pid, {exit_ok, Ret}} ->
Ret;
+ {'DOWN', Ref, process, Pid, {{nocatch, missing_doc}, _}} ->
+ throw(missing_doc);
{'DOWN', Ref, process, Pid, {{nocatch, {missing_stub,_} = Stub}, _}} ->
throw(Stub);
{'DOWN', Ref, process, Pid, request_uri_too_long} ->
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/75e5ba17/src/couch_replicator_worker.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_worker.erl b/src/couch_replicator_worker.erl
index bb31d5d..7a6cc96 100644
--- a/src/couch_replicator_worker.erl
+++ b/src/couch_replicator_worker.erl
@@ -295,6 +295,11 @@ fetch_doc(Source, {Id, Revs, PAs}, DocHandler, Acc) ->
couch_replicator_api_wrap:open_doc_revs(
Source, Id, Revs, [{atts_since, PAs}, latest], DocHandler, Acc)
catch
+ throw:missing_doc ->
+ couch_log:error("Retrying fetch and update of document `~s` as it is "
+ "unexpectedly missing. Missing revisions are: ~s",
+ [Id, couch_doc:revs_to_strs(Revs)]),
+ couch_replicator_api_wrap:open_doc_revs(Source, Id, Revs, [latest], DocHandler, Acc);
throw:{missing_stub, _} ->
couch_log:error("Retrying fetch and update of document `~s` due to out of "
"sync attachment stubs. Missing revisions are: ~s",
@@ -347,8 +352,8 @@ remote_doc_handler({ok, Doc}, {Parent, Target} = Acc) ->
end,
ok = gen_server:call(Parent, {add_stats, Stats2}, infinity),
Result;
-remote_doc_handler(_, Acc) ->
- {ok, Acc}.
+remote_doc_handler({{not_found, missing}, _}, _Acc) ->
+ throw(missing_doc).
spawn_writer(Target, #batch{docs = DocList, size = Size}) ->