anchor.diff:      {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 = ets:insert(?REP_ID_TO_DOC_ID, {BaseId, {DocId, true}}),
           true = ets:insert(?DOC_ID_TO_REP_ID, {DocId, RepId}),
  +        Server = self(),
           Pid = spawn_link(fun() ->
  -            start_replication(JsonRepDoc, RepId, UserCtx)
  +            start_replication(Server, JsonRepDoc, RepId, UserCtx)
           end),
           State#state{rep_start_pids = [Pid | State#state.rep_start_pids]};
  -    [{BaseId, DocId}] ->
  +    [{BaseId, {DocId, _}}] ->
           State;
  -    [{BaseId, OtherDocId}] ->
  +    [{BaseId, {OtherDocId, false}}] ->
           ?LOG_INFO("The replication specified by the document `~s` was already"
               " triggered by the document `~s`", [DocId, OtherDocId]),
  +        maybe_tag_rep_doc(JsonRepDoc, ?l2b(BaseId)),
  +        State;
  +    [{BaseId, {OtherDocId, true}}] ->
  +        ?LOG_INFO("The replication specified by the document `~s` is already"
  +            " being triggered by the document `~s`", [DocId, OtherDocId]),
           maybe_tag_rep_doc(JsonRepDoc, ?l2b(BaseId)),
           State
       end.
  
positive.code:     end.
  
  
  start_replication({RepProps} = RepDoc, {Base, _} = RepId, UserCtx) ->
      case (catch couch_rep:start_replication(RepDoc, RepId, UserCtx)) of
      Pid when is_pid(Pid) ->
          ?LOG_INFO("Document `~s` triggered replication `~s`",
              [get_value(<<"_id">>, RepProps), pp_rep_id(RepId)]),
          couch_rep:get_result(Pid, RepId, RepDoc, UserCtx);
      Error ->
          couch_rep:update_rep_doc(
              RepDoc,
              [
                  {<<"_replication_state">>, <<"error">>},
                  {<<"_replication_id">>, ?l2b(Base)}
              ]
          ),
          ?LOG_ERROR("Error starting replication `~s`: ~p", [pp_rep_id(RepId), Error])
      end.
  
  
  
negative.code: 
  -define(DOC_ID_TO_REP_ID, rep_doc_id_to_rep_id).
  -define(REP_ID_TO_DOC_ID, rep_id_to_rep_doc_id).
  -define(MAX_RETRIES, 10).
  -define(INITIAL_WAIT, 5).
  
  -record(state, {
      changes_feed_loop = nil,
  