You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by gi...@git.apache.org on 2017/06/28 20:44:07 UTC

[GitHub] davisp commented on a change in pull request #623: Ensure replicator _active_tasks entry reports recent pending changes

davisp 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_r124651323
 
 

 ##########
 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()},
+    ok = gen_server:call(Parent, Msg, infinity).
+
+
+maybe_process_changes(_Parent, [] = _Changes, _From, _Ts) ->
+    ok;
 
 Review comment:
   Pretty sure this will dead lock since you're sometimes not sending a message back to the From client.
 
----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services