anchor.diff:  
   handle_call({rep_db_update, Change}, _From, State) ->
       {reply, ok, process_update(State, Change)};
  +
  +handle_call({triggered, {BaseId, _}}, _From, State) ->
  +    case ets:lookup(?REP_ID_TO_DOC_ID, BaseId) of
  +    [{BaseId, {DocId, true}}] ->
  +        true = ets:insert(?REP_ID_TO_DOC_ID, {BaseId, {DocId, false}});
  +    _ ->
  +        ok
  +    end,
  +    {reply, ok, State};
  +
  +handle_call({restart_failure, {Props} = RepDoc, Error}, _From, State) ->
  +    DocId = get_value(<<"_id">>, Props),
  +    [{DocId, {BaseId, _} = RepId}] = ets:lookup(?DOC_ID_TO_REP_ID, DocId),
  +    ?LOG_ERROR("Failed to start replication `~s` after ~p attempts using "
  +        "the document `~s`. Last error reason was: ~p",
  +        [pp_rep_id(RepId), ?MAX_RETRIES, DocId, Error]),
  +    couch_rep:update_rep_doc(
  +        RepDoc,
  +        [{<<"_replication_state">>, <<"error">>},
  +            {<<"_replication_id">>, ?l2b(BaseId)}]),
  +    true = ets:delete(?REP_ID_TO_DOC_ID, BaseId),
  +    true = ets:delete(?DOC_ID_TO_REP_ID, DocId),
  +    {reply, ok, State};
   
   handle_call(Msg, From, State) ->
       ?LOG_ERROR("Replicator DB listener received unexpected call ~p from ~p",
  
positive.code:     {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(?DOC_ID_TO_REP_ID, {DocId, RepId}),
          Pid = spawn_link(fun() ->
              start_replication(JsonRepDoc, RepId, UserCtx)
          end),
          State#state{rep_start_pids = [Pid | State#state.rep_start_pids]};
      [{BaseId, DocId}] ->
          State;
      [{BaseId, OtherDocId}] ->
          ?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
      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,
  