couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r769109 - in /couchdb/trunk: share/www/script/test/delayed_commits.js src/couchdb/couch_db.erl
Date Mon, 27 Apr 2009 19:08:33 GMT
Author: damien
Date: Mon Apr 27 19:08:33 2009
New Revision: 769109

URL: http://svn.apache.org/viewvc?rev=769109&view=rev
Log:
Fix and test for COUCHDB-334 where a database with delayed commits pending is considered idle,
and subject to losing changes when shutdown

Modified:
    couchdb/trunk/share/www/script/test/delayed_commits.js
    couchdb/trunk/src/couchdb/couch_db.erl

Modified: couchdb/trunk/share/www/script/test/delayed_commits.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/delayed_commits.js?rev=769109&r1=769108&r2=769109&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/delayed_commits.js (original)
+++ couchdb/trunk/share/www/script/test/delayed_commits.js Mon Apr 27 19:08:33 2009
@@ -90,4 +90,26 @@
   
   T(db.open("4") != null);
   
+  // Now test that when we exceed the max_dbs_open, pending commits are safely
+  // written.
+  T(db.save({_id:"5",foo:"bar"}).ok);
+  var max = 2;
+  run_on_modified_server(
+    [{section: "couchdb",
+      key: "max_dbs_open",
+      value: max.toString()}],
+
+    function () {
+      for(var i=0; i<max; i++) {
+        var dbi = new CouchDB("test_suite_db" + i);
+        dbi.deleteDb();
+        dbi.createDb();
+      }
+      T(db.open("5").foo=="bar");
+      for(var i=0; i<max+1; i++) {
+        var dbi = new CouchDB("test_suite_db" + i);
+        dbi.deleteDb();
+      }
+    });
+  
 };

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=769109&r1=769108&r2=769109&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Mon Apr 27 19:08:33 2009
@@ -691,11 +691,11 @@
 handle_call({open_ref_count, OpenerPid}, _, #db{fd_ref_counter=RefCntr}=Db) ->
     ok = couch_ref_counter:add(RefCntr, OpenerPid),
     {reply, {ok, Db}, Db};
-handle_call(is_idle, _From,
-        #db{fd_ref_counter=RefCntr, compactor_pid=Compact}=Db) ->
+handle_call(is_idle, _From, #db{fd_ref_counter=RefCntr, compactor_pid=Compact, 
+            waiting_delayed_commit=Delay}=Db) ->
     % Idle means no referrers. Unless in the middle of a compaction file switch, 
     % there are always at least 2 referrers, couch_db_updater and us.
-    {reply, (Compact == nil) and (couch_ref_counter:count(RefCntr) == 2), Db};
+    {reply, (Delay == nil) and (Compact == nil) and (couch_ref_counter:count(RefCntr) ==
2), Db};
 handle_call({db_updated, #db{fd_ref_counter=NewRefCntr}=NewDb}, _From,
         #db{fd_ref_counter=OldRefCntr}) ->
     case NewRefCntr == OldRefCntr of



Mime
View raw message