Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 76132 invoked from network); 18 Nov 2010 11:12:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 18 Nov 2010 11:12:25 -0000 Received: (qmail 46537 invoked by uid 500); 18 Nov 2010 11:12:57 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 46429 invoked by uid 500); 18 Nov 2010 11:12:56 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 46422 invoked by uid 99); 18 Nov 2010 11:12:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Nov 2010 11:12:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Nov 2010 11:12:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0A5D423889B3; Thu, 18 Nov 2010 11:11:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1036408 - in /couchdb/branches/1.0.x: share/www/script/test/auth_cache.js src/couchdb/couch_auth_cache.erl Date: Thu, 18 Nov 2010 11:11:41 -0000 To: commits@couchdb.apache.org From: fdmanana@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101118111142.0A5D423889B3@eris.apache.org> Author: fdmanana Date: Thu Nov 18 11:11:41 2010 New Revision: 1036408 URL: http://svn.apache.org/viewvc?rev=1036408&view=rev Log: Merged revision 1036407 from trunk: 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/branches/1.0.x/share/www/script/test/auth_cache.js couchdb/branches/1.0.x/src/couchdb/couch_auth_cache.erl Modified: couchdb/branches/1.0.x/share/www/script/test/auth_cache.js URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/test/auth_cache.js?rev=1036408&r1=1036407&r2=1036408&view=diff ============================================================================== --- couchdb/branches/1.0.x/share/www/script/test/auth_cache.js (original) +++ couchdb/branches/1.0.x/share/www/script/test/auth_cache.js Thu Nov 18 11:11:41 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/branches/1.0.x/src/couchdb/couch_auth_cache.erl URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_auth_cache.erl?rev=1036408&r1=1036407&r2=1036408&view=diff ============================================================================== --- couchdb/branches/1.0.x/src/couchdb/couch_auth_cache.erl (original) +++ couchdb/branches/1.0.x/src/couchdb/couch_auth_cache.erl Thu Nov 18 11:11:41 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 ->