anchor.diff:                  fun({change, Change, _}, _) ->
                       case has_valid_rep_id(Change) of
                       true ->
  -                        couch_work_queue:queue(ChangesQueue, Change);
  +                        ok = gen_server:call(
  +                            Server, {rep_db_update, Change}, infinity);
                       false ->
                           ok
                       end;
  
positive.code:                 {<<"_replication_id">>, ?l2b(Base)}
              ]
          ),
          ?LOG_ERROR("Error starting replication `~s`: ~p", [Base ++ Ext, Error])
      end.
  
  rep_doc_deleted(DocId) ->
      case stop_replication(DocId) of
      {ok, {Base, Ext}} ->
          ?LOG_INFO("Stopped replication `~s` because replication document `~s`"
              " was deleted", [Base ++ Ext, DocId]);
      none ->
          ok
      end.
  
  replication_complete(DocId) ->
      case stop_replication(DocId) of
      {ok, {Base, Ext}} ->
          ?LOG_INFO("Replication `~s` finished (triggered by document `~s`)",
              [Base ++ Ext, DocId]);
      none ->
          ok
      end.
  
  stop_replication(DocId) ->
      case ets:lookup(?DOC_TO_REP_ID_MAP, DocId) of
      [{DocId, {BaseId, _} = RepId}] ->
          couch_rep:end_replication(RepId),
          true = ets:delete(?REP_ID_TO_DOC_ID_MAP, BaseId),
          true = ets:delete(?DOC_TO_REP_ID_MAP, DocId),
          {ok, RepId};
      [] ->
          none
      end.
  
  stop_all_replications() ->
      ets:foldl(
          fun({_, RepId}, _) -> couch_rep:end_replication(RepId) end,
          ok,
          ?DOC_TO_REP_ID_MAP
      ),
      true = ets:delete_all_objects(?REP_ID_TO_DOC_ID_MAP),
      true = ets:delete_all_objects(?DOC_TO_REP_ID_MAP).
  
negative.code:         end
      ),
      couch_db:close(RepDb),
      {Pid, couch_db:name(RepDb)}.
  
  
  has_valid_rep_id({Change}) ->
      has_valid_rep_id(get_value(<<"id">>, Change));
  has_valid_rep_id(<<?DESIGN_DOC_PREFIX, _Rest/binary>>) ->
      false;
  has_valid_rep_id(_Else) ->
      true.
  
  
  db_update_notifier() ->
  