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 2020/02/17 16:59:38 UTC

[couchdb] branch fix-seedlist-when-usersdb-not-created-3.0.x updated (a84924e -> 154e05b)

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

vatamane pushed a change to branch fix-seedlist-when-usersdb-not-created-3.0.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard a84924e  Handle possibly missing local _users db in mem3_sync:local_dbs()
     new 154e05b  Handle possibly missing local _users db in mem3_sync:local_dbs()

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (a84924e)
            \
             N -- N -- N   refs/heads/fix-seedlist-when-usersdb-not-created-3.0.x (154e05b)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/mem3/src/mem3_sync.erl | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)


[couchdb] 01/01: Handle possibly missing local _users db in mem3_sync:local_dbs()

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch fix-seedlist-when-usersdb-not-created-3.0.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 154e05bab9384324d5564287c89c47757b4c4d15
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Mon Feb 17 11:39:28 2020 -0500

    Handle possibly missing local _users db in mem3_sync:local_dbs()
    
    After commit 27bb45043435828915bdcbdc130b685e5533bbd8 local _users is only
    created the first time it is used. So in most case it's expected to not exist.
    Update local_dbs to return it only if it is actually created.
---
 src/mem3/src/mem3_sync.erl              |  7 ++++++-
 src/mem3/test/eunit/mem3_seeds_test.erl | 16 ++++++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/mem3/src/mem3_sync.erl b/src/mem3/src/mem3_sync.erl
index 8170f3c..cfed6a4 100644
--- a/src/mem3/src/mem3_sync.erl
+++ b/src/mem3/src/mem3_sync.erl
@@ -302,7 +302,12 @@ remove_entries(Dict, Entries) ->
     end, Dict, Entries).
 
 local_dbs() ->
-    [nodes_db(), shards_db(), users_db()].
+    UsersDb = users_db(),
+    % users db might not have been created so don't include it unless it exists
+    case couch_server:exists(UsersDb) of
+        true -> [nodes_db(), shards_db(), UsersDb];
+        false -> [nodes_db(), shards_db()]
+    end.
 
 nodes_db() ->
     ?l2b(config:get("mem3", "nodes_db", "_nodes")).
diff --git a/src/mem3/test/eunit/mem3_seeds_test.erl b/src/mem3/test/eunit/mem3_seeds_test.erl
index ba83b66..ac32282 100644
--- a/src/mem3/test/eunit/mem3_seeds_test.erl
+++ b/src/mem3/test/eunit/mem3_seeds_test.erl
@@ -18,7 +18,8 @@ a_test_() ->
     Tests = [
         {"empty seedlist should set status ok", fun empty_seedlist_status_ok/0},
         {"all seedlist nodes unreachable keeps status seeding", fun seedlist_misconfiguration/0},
-        {"seedlist entries should be present in _nodes", fun check_nodelist/0}
+        {"seedlist entries should be present in _nodes", fun check_nodelist/0},
+        {"optional local _users db in mem3_sync:local_dbs()", fun check_local_dbs/0}
     ],
     {setup, fun setup/0, fun teardown/1, Tests}.
 
@@ -57,10 +58,21 @@ check_nodelist() ->
         cleanup()
     end.
 
+check_local_dbs() ->
+    ?assertEqual([<<"_dbs">>, <<"_nodes">>],
+        lists:sort(mem3_sync:local_dbs())),
+    {ok, _} = couch_server:create(<<"_users">>, []),
+    ?assertEqual([<<"_dbs">>, <<"_nodes">>, <<"_users">>],
+        lists:sort(mem3_sync:local_dbs())).
+
 cleanup() ->
     application:stop(mem3),
     Filename = config:get("mem3", "nodes_db", "_nodes") ++ ".couch",
-    file:delete(filename:join([?BUILDDIR(), "tmp", "data", Filename])).
+    file:delete(filename:join([?BUILDDIR(), "tmp", "data", Filename])),
+    case config:get("couch_httpd_auth", "authentication_db") of
+        undefined -> ok;
+        DbName -> couch_server:delete(list_to_binary(DbName), [])
+    end.
 
 setup() ->
     test_util:start_couch([rexi]).