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/08/28 14:15:34 UTC
[03/37] couch-replicator commit: updated refs/heads/master to aafb5f9
Handle last_seq returns from failed filters
Fabric changes will now return a last sequence when the continuous request has timed out but docs
have failed to pass the filter. This enables more accurate tracking of progress.
BugzID: 17709
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/78983131
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/78983131
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/78983131
Branch: refs/heads/master
Commit: 789831310b75b19c43ef3037e1abd36bc7bd9bb4
Parents: 8d03f0c
Author: Bob Dionne <bo...@cloudant.com>
Authored: Mon Mar 4 09:48:33 2013 -0500
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Jul 29 12:38:53 2014 +0100
----------------------------------------------------------------------
src/couch_replicator.erl | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/78983131/src/couch_replicator.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator.erl b/src/couch_replicator.erl
index d2cdbe5..895bbcc 100644
--- a/src/couch_replicator.erl
+++ b/src/couch_replicator.erl
@@ -408,6 +408,8 @@ handle_call({report_seq_done, Seq, StatsInc}, From,
current_through_seq = ThroughSeq, stats = Stats} = State) ->
gen_server:reply(From, ok),
{NewThroughSeq0, NewSeqsInProgress} = case SeqsInProgress of
+ [] ->
+ {Seq, []};
[Seq | Rest] ->
{Seq, Rest};
[_ | _] ->
@@ -623,17 +625,19 @@ fold_replication_logs([Db | Rest] = Dbs, Vsn, LogId, NewId, Rep, Acc) ->
spawn_changes_reader(StartSeq, #httpdb{} = Db, ChangesQueue, Options) ->
+ Parent = self(),
spawn_link(fun() ->
put(last_seq, StartSeq),
put(retries_left, Db#httpdb.retries),
- read_changes(StartSeq, Db#httpdb{retries = 0}, ChangesQueue, Options)
+ read_changes(Parent, StartSeq, Db#httpdb{retries = 0}, ChangesQueue, Options, 1)
end);
spawn_changes_reader(StartSeq, Db, ChangesQueue, Options) ->
+ Parent = self(),
spawn_link(fun() ->
- read_changes(StartSeq, Db, ChangesQueue, Options)
+ read_changes(Parent, StartSeq, Db, ChangesQueue, Options, 1)
end).
-read_changes(StartSeq, Db, ChangesQueue, Options) ->
+read_changes(Parent, StartSeq, Db, ChangesQueue, Options, Ts) ->
try
couch_replicator_api_wrap:changes_since(Db, all_docs, StartSeq,
fun(#doc_info{high_seq = Seq, id = Id} = DocInfo) ->
@@ -655,7 +659,9 @@ read_changes(StartSeq, Db, ChangesQueue, Options) ->
% LS should never be undefined, but it doesn't hurt to be
% defensive inside the replicator.
Seq = case LS of undefined -> get(last_seq); _ -> LS end,
- read_changes(Seq, Db, ChangesQueue, Options);
+ ok = gen_server:call(Parent, {report_seq_done, {Ts, Seq}, #rep_stats{}}, infinity),
+ put(last_seq, Seq),
+ read_changes(Parent, Seq, Db, ChangesQueue, Options, Ts + 1);
_ ->
% This clause is unreachable today, but let's plan ahead
% for the future where we checkpoint against last_seq
@@ -682,7 +688,7 @@ read_changes(StartSeq, Db, ChangesQueue, Options) ->
" with since=~p", [couch_replicator_api_wrap:db_uri(Db), LastSeq]),
Db
end,
- read_changes(LastSeq, Db2, ChangesQueue, Options);
+ read_changes(Parent, LastSeq, Db2, ChangesQueue, Options, Ts);
_ ->
exit(Error)
end