anchor.diff:      Pid when is_pid(Pid) ->
           ok = gen_server:call(Server, {triggered, RepId}, infinity),
           {RepProps} = RepDoc,
  +        DocId = get_value(<<"_id">>, RepProps),
  +        [{DocId, {RepId, MaxRetries}}] = ets:lookup(?DOC_ID_TO_REP_ID, DocId),
           ?LOG_INFO("Document `~s` triggered replication `~s` after ~p attempts",
  -            [get_value(<<"_id">>, RepProps), pp_rep_id(RepId),
  -                ?MAX_RETRIES - RetriesLeft + 1]),
  +            [DocId, pp_rep_id(RepId), MaxRetries - RetriesLeft + 1]),
           couch_rep:get_result(Pid, RepId, RepDoc, UserCtx);
       NewError ->
           keep_retrying(
  
positive.code: 
  handle_cast({rep_db_created, _NewName}, State) ->
      {noreply, restart(State)};
  
  handle_cast(Msg, State) ->
      ?LOG_ERROR("Replicator DB listener received unexpected cast ~p", [Msg]),
  
negative.code:     end.
  
  
  maybe_start_replication(#state{max_retries = MaxRetries} = State,
          DocId, JsonRepDoc) ->
      UserCtx = rep_user_ctx(JsonRepDoc),
      {BaseId, _} = RepId = couch_rep:make_replication_id(JsonRepDoc, UserCtx),
      case ets:lookup(?REP_ID_TO_DOC_ID, BaseId) of
      [] ->
          true = ets:insert(?REP_ID_TO_DOC_ID, {BaseId, {DocId, true}}),
          true = ets:insert(?DOC_ID_TO_REP_ID, {DocId, {RepId, MaxRetries}}),
          Server = self(),
          Pid = spawn_link(fun() ->
              start_replication(Server, JsonRepDoc, RepId, UserCtx, MaxRetries)
          end),
          State#state{rep_start_pids = [Pid | State#state.rep_start_pids]};
      [{BaseId, {DocId, _}}] ->
  