couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1036407 - in /couchdb/trunk: share/www/script/test/auth_cache.js src/couchdb/couch_auth_cache.erl
Date Thu, 18 Nov 2010 11:11:00 GMT
Author: fdmanana
Date: Thu Nov 18 11:11:00 2010
New Revision: 1036407

URL: http://svn.apache.org/viewvc?rev=1036407&view=rev
Log:
Make sure that after compaction of the authentication database the old reference counter is
released.
Same type of issue as in COUCHDB-926.


Modified:
    couchdb/trunk/share/www/script/test/auth_cache.js
    couchdb/trunk/src/couchdb/couch_auth_cache.erl

Modified: couchdb/trunk/share/www/script/test/auth_cache.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/auth_cache.js?rev=1036407&r1=1036406&r2=1036407&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/auth_cache.js (original)
+++ couchdb/trunk/share/www/script/test/auth_cache.js Thu Nov 18 11:11:00 2010
@@ -238,6 +238,37 @@ couchTests.auth_cache = function(debug) 
 
     T(misses_after === misses_before);
     T(hits_after === (hits_before + 1));
+
+    // login, compact authentication DB, login again and verify that
+    // there was a cache hit
+    hits_before = hits_after;
+    misses_before = misses_after;
+
+    T(CouchDB.login("johndoe", "123456").ok);
+
+    hits_after = hits();
+    misses_after = misses();
+
+    T(misses_after === (misses_before + 1));
+    T(hits_after === hits_before);
+
+    T(CouchDB.logout().ok);
+    T(authDb.compact().ok);
+
+    while (authDb.info().compact_running);
+
+    hits_before = hits_after;
+    misses_before = misses_after;
+
+    T(CouchDB.login("johndoe", "123456").ok);
+
+    hits_after = hits();
+    misses_after = misses();
+
+    T(misses_after === misses_before);
+    T(hits_after === (hits_before + 1));
+
+    T(CouchDB.logout().ok);
   }
 
 

Modified: couchdb/trunk/src/couchdb/couch_auth_cache.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_auth_cache.erl?rev=1036407&r1=1036406&r2=1036407&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_auth_cache.erl (original)
+++ couchdb/trunk/src/couchdb/couch_auth_cache.erl Thu Nov 18 11:11:00 2010
@@ -135,6 +135,7 @@ handle_db_event({Event, DbName}) ->
         case Event of
         deleted -> gen_server:call(?MODULE, auth_db_deleted, infinity);
         created -> gen_server:call(?MODULE, auth_db_created, infinity);
+        compacted -> gen_server:call(?MODULE, auth_db_compacted, infinity);
         _Else   -> ok
         end;
     false ->
@@ -158,6 +159,14 @@ handle_call(auth_db_created, _From, Stat
     true = ets:insert(?STATE, {auth_db, open_auth_db()}),
     {reply, ok, NewState};
 
+handle_call(auth_db_compacted, _From, State) ->
+    exec_if_auth_db(
+        fun(AuthDb) ->
+            true = ets:insert(?STATE, {auth_db, reopen_auth_db(AuthDb)})
+        end
+    ),
+    {reply, ok, State};
+
 handle_call({new_max_cache_size, NewSize}, _From, State) ->
     case NewSize >= State#state.cache_size of
     true ->



Mime
View raw message