anchor.diff:  update_rep_doc(RepDocId, KVs) ->
       {ok, RepDb} = ensure_rep_db_exists(),
       try
  -        {ok, LatestRepDoc} = couch_db:open_doc(RepDb, RepDocId, []),
  -        update_rep_doc(RepDb, LatestRepDoc, KVs)
  +        case couch_db:open_doc(RepDb, RepDocId, []) of
  +        {ok, LatestRepDoc} ->
  +            update_rep_doc(RepDb, LatestRepDoc, KVs);
  +        _ ->
  +            ok
  +        end
       catch throw:conflict ->
           % Shouldn't happen, as by default only the role _replicator can
           % update replication documents.
  
positive.code:     rep,
      starting,
      retries_left,
      max_retries
  }).
  
  -import(couch_replicator_utils, [
  
negative.code:     {reply, ok, process_update(State, Change)};
  
  handle_call({rep_started, {BaseId, _Ext} = RepId}, _From, State) ->
      case rep_state(RepId) of
      nil ->
          ok;
      #rep_state{rep = #rep{doc_id = DocId}} = RepState ->
          true = ets:insert(
              ?REP_TO_STATE, {RepId, RepState#rep_state{starting = false}}),
          update_rep_doc(DocId, [
              {<<"_replication_state">>, <<"triggered">>},
              {<<"_replication_id">>, ?l2b(BaseId)}]),
          ?LOG_INFO("Document `~s` triggered replication `~s`",
              [DocId, pp_rep_id(RepId)])
      end,
      {reply, ok, State};
  
  handle_call({rep_complete, RepId}, _From, State) ->
      case rep_state(RepId) of
      nil ->
          ok;
      #rep_state{rep = #rep{doc_id = DocId}} ->
          update_rep_doc(DocId, [{<<"_replication_state">>, <<"completed">>}])
      end,
      {reply, ok, State};
  
  handle_call({rep_error, RepId, Error}, _From, State) ->
      case rep_state(RepId) of
      nil ->
          {reply, ok, State};
      #rep_state{rep = #rep{doc_id = DocId}} = RepState ->
          NewRepState = RepState#rep_state{last_error = Error},
          true = ets:insert(?REP_TO_STATE, {RepId, NewRepState}),
          % TODO: maybe add error reason to replication document
          update_rep_doc(DocId, [{<<"_replication_state">>, <<"error">>}]),
          {reply, ok, State}
      end;
  
  handle_call(Msg, From, State) ->
      ?LOG_ERROR("Replication manager received unexpected call ~p from ~p",
  