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:55:52 UTC

[couchdb] branch fix-seedlist-when-usersdb-not-created-master created (now 05661f2)

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

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


      at 05661f2  Handle possibly missing local _users db in mem3_sync:local_dbs()

This branch includes the following new commits:

     new 05661f2  Handle possibly missing local _users db in mem3_sync:local_dbs()

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.



[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-master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 05661f2252d677fc4c0984461fec0adf3f602cc5
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              |  8 +++++++-
 src/mem3/test/eunit/mem3_seeds_test.erl | 16 ++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/mem3/src/mem3_sync.erl b/src/mem3/src/mem3_sync.erl
index 8170f3c..df75b95 100644
--- a/src/mem3/src/mem3_sync.erl
+++ b/src/mem3/src/mem3_sync.erl
@@ -302,7 +302,13 @@ 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 return unless it exists
+    % other dbs are guaranteed to exist on cluster startup
+    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]).