rnewson commented on a change in pull request #721: Save migrated replicator 
checkpoint documents immediately
URL: https://github.com/apache/couchdb/pull/721#discussion_r130389135
 
 

 ##########
 File path: src/couch_replicator/src/couch_replicator_scheduler_job.erl
 ##########
 @@ -632,11 +632,30 @@ fold_replication_logs([Db | Rest] = Dbs, Vsn, LogId, 
NewId, Rep, Acc) ->
             Rest, ?REP_ID_VERSION, NewId, NewId, Rep, [Doc | Acc]);
     {ok, Doc} ->
         MigratedLog = #doc{id = NewId, body = Doc#doc.body},
+        maybe_save_migrated_log(Rep, Db, MigratedLog, Doc#doc.id),
         fold_replication_logs(
             Rest, ?REP_ID_VERSION, NewId, NewId, Rep, [MigratedLog | Acc])
     end.
 
 
+maybe_save_migrated_log(Rep, Db, #doc{} = Doc, OldId) ->
+    case get_value(use_checkpoints, Rep#rep.options, true) of
+        true ->
+            DbName = httpdb_strip_creds(Db),
+            try
+                update_checkpoint(Db, Doc),
+                OkMsg = "Migrated replication checkpoint. Db:~p ~p -> ~p",
+                couch_log:notice(OkMsg,  [DbName, OldId, Doc#doc.id])
+            catch
 
 Review comment:
   I'm not sure why we're catching, logging, then ignoring this condition? let 
it crash?
 
----------------------------------------------------------------
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

Reply via email to