You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/06/17 15:48:26 UTC

[couchdb] 02/06: Fix broken cache update

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

davisp pushed a commit to branch prototype/fdb-layer-db-version-as-vstamps
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit da7ba5e41efb99a8989d3b7889e5c7ac5ed53ed0
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Jun 4 15:13:15 2020 -0500

    Fix broken cache update
    
    The underlying `set_config/3` call ends up bumping the metadata version
    which results in invalidtaing the entire db cache. Storing an updated
    version on the db handle is unproductive becuase we are unable to get
    the new metadata version.
---
 src/fabric/src/fabric2_db.erl             | 14 ++++----------
 src/fabric/test/fabric2_db_misc_tests.erl |  2 +-
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/fabric/src/fabric2_db.erl b/src/fabric/src/fabric2_db.erl
index 667cf35..68886b9 100644
--- a/src/fabric/src/fabric2_db.erl
+++ b/src/fabric/src/fabric2_db.erl
@@ -603,25 +603,19 @@ is_users_db(DbName) when is_binary(DbName) ->
 
 set_revs_limit(#{} = Db0, RevsLimit) when is_integer(RevsLimit) ->
     Db1 = require_admin_check(Db0),
-    Resp = fabric2_fdb:transactional(Db1, fun(TxDb) ->
+    fabric2_fdb:transactional(Db1, fun(TxDb) ->
         fabric2_fdb:set_config(TxDb, revs_limit, RevsLimit)
     end),
-    case Resp of
-        {ok, #{} = Db2} -> fabric2_server:store(Db2);
-        Err -> Err
-    end.
+    fabric2_server:remove(name(Db0)).
 
 
 set_security(#{} = Db0, Security) ->
     Db1 = require_admin_check(Db0),
     ok = fabric2_util:validate_security_object(Security),
-    Resp = fabric2_fdb:transactional(Db1, fun(TxDb) ->
+    fabric2_fdb:transactional(Db1, fun(TxDb) ->
         fabric2_fdb:set_config(TxDb, security_doc, Security)
     end),
-    case Resp of
-        {ok, #{} = Db2} -> fabric2_server:store(Db2);
-        Err -> Err
-    end.
+    fabric2_server:remove(name(Db0)).
 
 
 set_user_ctx(#{} = Db, UserCtx) ->
diff --git a/src/fabric/test/fabric2_db_misc_tests.erl b/src/fabric/test/fabric2_db_misc_tests.erl
index 2353214..a8a2677 100644
--- a/src/fabric/test/fabric2_db_misc_tests.erl
+++ b/src/fabric/test/fabric2_db_misc_tests.erl
@@ -129,7 +129,7 @@ get_security_cached({DbName, Db, _}) ->
 
     % Set directly so we don't auto-update the local cache
     {ok, Db1} = fabric2_db:open(DbName, [?ADMIN_CTX]),
-    ?assertMatch({ok, #{}}, fabric2_fdb:transactional(Db1, fun(TxDb) ->
+    ?assertEqual(ok, fabric2_fdb:transactional(Db1, fun(TxDb) ->
         fabric2_fdb:set_config(TxDb, security_doc, SecObj)
     end)),