nickva commented on a change in pull request #623: Ensure replicator
_active_tasks entry reports recent pending changes
URL: https://github.com/apache/couchdb/pull/623#discussion_r124656998
##########
File path: src/couch_replicator/src/couch_replicator_scheduler_job.erl
##########
@@ -652,16 +652,38 @@ changes_manager_loop_open(Parent, ChangesQueue,
BatchSize, Ts) ->
case couch_work_queue:dequeue(ChangesQueue, BatchSize) of
closed ->
From ! {closed, self()};
- {ok, Changes} ->
- #doc_info{high_seq = Seq} = lists:last(Changes),
- ReportSeq = {Ts, Seq},
- ok = gen_server:cast(Parent, {report_seq, ReportSeq}),
- From ! {changes, self(), Changes, ReportSeq}
+ {ok, ChangesOrLastSeqs} ->
+ {LastSeqs, Changes} = lists:partition(
+ fun({last_seq, _Seq}) ->
+ true;
+ (#doc_info{}) ->
+ false
+ end, ChangesOrLastSeqs),
+ ok = maybe_report_last_sequence(Parent, LastSeqs, Ts),
+ ok = maybe_process_changes(Parent, Changes, From, Ts)
end,
changes_manager_loop_open(Parent, ChangesQueue, BatchSize, Ts + 1)
end.
+maybe_report_last_sequence(_Parent, [] = _LastSeqs, _Ts) ->
+ ok;
+maybe_report_last_sequence(Parent, LastSeqs, Ts) ->
+ {last_seq, Seq} = lists:last(LastSeqs),
+ Msg = {report_seq_done, {Ts, Seq}, couch_replicator_stats:new()},
Review comment:
But I'll switch the order. I think it would make more sense.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services