anchor.diff:              exit({failed_write, Props})
       end.
   
  +%% return list of Docsinfos of missing keys
  +-spec find_missing(list(), #httpdb{}) -> list().
   find_missing(DocInfos, Target) ->
       {IdRevs, AllRevsCount} = lists:foldr(
                                  fun(#doc_info{id = Id, rev = Rev}, {IdRevAcc, CountAcc}) ->
  
positive.code:     {ok, DataRepd1} = local_process_batch([], Cp, Source, Target, #batch{}),
      {ok, DataRepd1 + Size};
  
  local_process_batch([IdRevs | Rest], Cp, #db{} = Source,
                      #httpdb{} = Target, Batch) ->
      {ok, {_, DocList, _}} = fetch_doc(
                                        Source, IdRevs, fun local_doc_handler/2,
                                        {Target, [], Cp}),
      {Batch2, DataFlushed} = lists:foldl(
                           fun(Doc, {Batch0, DataFlushed1}) ->
  
negative.code:         {'DOWN', _, _, _, _} ->
              ok = gen_server:call(Cp, {worker_done, self()}, infinity);
          {changes, ChangesManager, Changes, ReportSeq} ->
              %% get docinfo of missing ids
              MissingDocInfoList = find_missing(Changes, Target),
              NumChecked = length(Changes),
              %% use ptr in docinfo to fetch document from storage
              {ok, DataRepd} = local_process_batch(
                                 MissingDocInfoList, Cp, Source, Target, #batch{}),
              ok = gen_server:call(Cp, {report_seq_done, ReportSeq, NumChecked, length(MissingDocInfoList), DataRepd}, infinity),
              ?xdcr_debug("Worker reported completion of seq ~p", [ReportSeq]),
              queue_fetch_loop(Source, Target, Cp, ChangesManager)
      end.
  