anchor.diff:      true = ets:delete_all_objects(?DOC_TO_REP),
       true = ets:delete_all_objects(?DB_TO_SEQ).
   
  +clean_up_replications(DbName) ->
  +    ets:foldl(
  +        fun({{Name, DocId}, RepId}, _) when Name =:= DbName ->
  +            couch_replicator:cancel_replication(RepId),
  +            ets:delete(?DOC_TO_REP,{Name, DocId}),
  +            ets:delete(?REP_TO_STATE, RepId);
  +           ({_,_}, _) ->
  +            ok
  +        end,
  +        ok, ?DOC_TO_REP),
  +    ets:delete(?DB_TO_SEQ,DbName).
  +
   
   update_rep_doc(RepDbName, RepDocId, KVs) when is_binary(RepDocId) ->
       {Pid, Ref} =
  
positive.code: init(_) ->
      process_flag(trap_exit, true),
      net_kernel:monitor_nodes(true),
      ?DOC_TO_REP = ets:new(?DOC_TO_REP, [named_table, set, protected]),
      ?REP_TO_STATE = ets:new(?REP_TO_STATE, [named_table, set, protected]),
      ?DB_TO_SEQ = ets:new(?DB_TO_SEQ, [named_table, set, protected]),
      Server = self(),
      ok = couch_config:register(
          fun("replicator", "max_replication_retry_count", V) ->
  
negative.code:         fun({updated, DbName}) ->
              case IsReplicatorDbFun(DbName) of
              true ->
                  ok = gen_server:call(Server, {resume_scan, mem3:dbname(DbName)}, infinity);
              _ ->
                  ok
              end;
             ({deleted, DbName}) ->
              case IsReplicatorDbFun(DbName) of
              true ->
                  clean_up_replications(mem3:dbname(DbName));
              _ ->
                  ok
              end;
  