anchor.diff:      {reply, ok, replication_error(State, RepId, Error)};
   
   handle_call({rep_db_checkpoint, DbName, EndSeq}, _From, State) ->
  -    true = ets:insert(?DB_TO_SEQ, {DbName, EndSeq}),
  +    Entry = case ets:lookup(?DB_TO_SEQ, DbName) of
  +        [] ->
  +            {DbName, EndSeq, false};
  +        [{DbName, _OldSeq, Rescan}] ->
  +            {DbName, EndSeq, Rescan}
  +    end,
  +    true = ets:insert(?DB_TO_SEQ, Entry),
       {reply, ok, State};
   
   handle_call(rep_db_changed, _From, State) ->
  
positive.code:     couch_log:error("Database update notifier died. Reason: ~p", [Reason]),
      {stop, {db_update_notifier_died, Reason}, State};
  
  handle_info({'EXIT', From, normal}, #state{rep_start_pids = Pids} = State) ->
      % one of the replication start processes terminated successfully
      {noreply, State#state{rep_start_pids = Pids -- [From]}};
  
  handle_info({'EXIT', From, Reason}, #state{rep_start_pids = Pids} = State) ->
      case lists:member(From, Pids) of
          true ->
              Fmt = "~s : Known replication pid ~w died :: ~w",
              couch_log:error(Fmt, [?MODULE, From, Reason]),
              {noreply, State#state{rep_start_pids = Pids -- [From]}};
          false ->
              Fmt = "~s : Unknown pid ~w died :: ~w",
              couch_log:error(Fmt, [?MODULE, From, Reason]),
  
negative.code:         couch_log:notice("Delaying replication `~s` start by ~p seconds.",
              [pp_rep_id(RepId), DelaySecs]),
          Pid = spawn_link(?MODULE, start_replication, [Rep, DelaySecs]),
          State#state{
              rep_start_pids = [{rep_start, Pid} | State#state.rep_start_pids]
          };
      #rep_state{rep = #rep{doc_id = DocId}} ->
          State;
      #rep_state{starting = false, rep = #rep{db_name = DbName, doc_id = OtherDocId}} ->
  