You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2019/10/10 15:52:02 UTC

[couchdb] 01/01: Stop creating node local _replicator db

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch dont-auto-create-node-local-replicator-db
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 1b2d5c059e080828d72908784c01fb2bd9fbec6f
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Thu Oct 10 11:48:57 2019 -0400

    Stop creating node local _replicator db
    
    We don't support "local" replications in 3.x so there is not need to waste
    resoruces creating this db on every node, and then continuously listening for
    replication doc updates from it.
---
 src/couch_replicator/README.md                     |  8 --------
 src/couch_replicator/src/couch_replicator.erl      |  9 ---------
 src/couch_replicator/src/couch_replicator_docs.erl | 15 ---------------
 src/couch_replicator/src/couch_replicator_sup.erl  |  9 ---------
 4 files changed, 41 deletions(-)

diff --git a/src/couch_replicator/README.md b/src/couch_replicator/README.md
index 9822f27..6a2a5cf 100644
--- a/src/couch_replicator/README.md
+++ b/src/couch_replicator/README.md
@@ -278,14 +278,6 @@ A description of each child:
         of replications running, having each one checking their filter often is
         not a good idea.
 
- * `couch_replicator`: This is an unusual but useful pattern. This child is not
-   an actual process but a one-time call to the
-   `couch_replicator:ensure_rep_db_exists/0` function, executed by the
-   supervisor in the correct order (and monitored for crashes). This ensures
-   the local replicator db exists, then returns `ignore`. This pattern is
-   useful for doing setup-like things at the top level and in the correct order
-   regarding the rest of the children in the supervisor.
-
  * `couch_replicator_db_changes`: This process specializes and configures
    `couch_multidb_changes` so that it looks for `_replicator` suffixed shards
    and makes sure to restart it when node membership changes.
diff --git a/src/couch_replicator/src/couch_replicator.erl b/src/couch_replicator/src/couch_replicator.erl
index 9c7e318..f3cd564 100644
--- a/src/couch_replicator/src/couch_replicator.erl
+++ b/src/couch_replicator/src/couch_replicator.erl
@@ -14,7 +14,6 @@
 
 -export([
     replicate/2,
-    ensure_rep_db_exists/0,
     replication_states/0,
     job/1,
     doc/3,
@@ -79,14 +78,6 @@ replicate(PostBody, Ctx) ->
     end.
 
 
-% This is called from supervisor. Must respect supervisor protocol so
-% it returns `ignore`.
--spec ensure_rep_db_exists() -> ignore.
-ensure_rep_db_exists() ->
-    {ok, _Db} = couch_replicator_docs:ensure_rep_db_exists(),
-    ignore.
-
-
 -spec do_replication_loop(#rep{}) ->
     {ok, {continuous, binary()}} | {ok, tuple()} | {error, any()}.
 do_replication_loop(#rep{id = {BaseId, Ext} = Id, options = Options} = Rep) ->
diff --git a/src/couch_replicator/src/couch_replicator_docs.erl b/src/couch_replicator/src/couch_replicator_docs.erl
index e233441..d097a16 100644
--- a/src/couch_replicator/src/couch_replicator_docs.erl
+++ b/src/couch_replicator/src/couch_replicator_docs.erl
@@ -20,7 +20,6 @@
     parse_rep_doc_without_id/2,
     before_doc_update/3,
     after_doc_read/2,
-    ensure_rep_db_exists/0,
     ensure_rep_ddoc_exists/1,
     ensure_cluster_rep_ddoc_exists/1,
     remove_state_fields/2,
@@ -121,20 +120,6 @@ update_error(#rep{db_name = DbName, doc_id = DocId, id = RepId}, Error) ->
     ok.
 
 
--spec ensure_rep_db_exists() -> {ok, Db::any()}.
-ensure_rep_db_exists() ->
-    Db = case couch_db:open_int(?REP_DB_NAME, [?CTX, sys_db,
-            nologifmissing]) of
-        {ok, Db0} ->
-            Db0;
-        _Error ->
-            {ok, Db0} = couch_db:create(?REP_DB_NAME, [?CTX, sys_db]),
-            Db0
-    end,
-    ok = ensure_rep_ddoc_exists(?REP_DB_NAME),
-    {ok, Db}.
-
-
 -spec ensure_rep_ddoc_exists(binary()) -> ok.
 ensure_rep_ddoc_exists(RepDb) ->
     case mem3:belongs(RepDb, ?REP_DESIGN_DOC) of
diff --git a/src/couch_replicator/src/couch_replicator_sup.erl b/src/couch_replicator/src/couch_replicator_sup.erl
index 5475e8f..cd4512c 100644
--- a/src/couch_replicator/src/couch_replicator_sup.erl
+++ b/src/couch_replicator/src/couch_replicator_sup.erl
@@ -62,15 +62,6 @@ init(_Args) ->
             brutal_kill,
             worker,
             [couch_replicator_doc_processor]},
-        {couch_replicator,
-            % This is a simple function call which does not create a process
-            % but returns `ignore`. It is used to make sure each node
-            % has a local `_replicator` database.
-            {couch_replicator, ensure_rep_db_exists, []},
-            transient,
-            brutal_kill,
-            worker,
-            [couch_replicator]},
         {couch_replicator_db_changes,
             {couch_replicator_db_changes, start_link, []},
             permanent,