couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r884369 - in /couchdb/trunk: share/www/script/test/stats.js src/couchdb/couch_db_updater.erl
Date Thu, 26 Nov 2009 02:10:06 GMT
Author: davisp
Date: Thu Nov 26 02:10:06 2009
New Revision: 884369

URL: http://svn.apache.org/viewvc?rev=884369&view=rev
Log:
Refactored the fix for active_dbs timeouts.

I was getting a bit of weirdness with the old test version so I updated to be more straight
forward in its testing. I've also updated the patch to couch_db_updater.erl to only to the
db_updated call when a delayed commit changes the db because it was interacting badly with
compaction.


Modified:
    couchdb/trunk/share/www/script/test/stats.js
    couchdb/trunk/src/couchdb/couch_db_updater.erl

Modified: couchdb/trunk/share/www/script/test/stats.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/stats.js?rev=884369&r1=884368&r2=884369&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/stats.js (original)
+++ couchdb/trunk/share/www/script/test/stats.js Thu Nov 26 02:10:06 2009
@@ -85,28 +85,21 @@
       // that we've waited for more than 1 second since opening
       // the first database so that any delayed commits will be
       // flushed.
-      var times = [];
+      var triggered = false;
+      var db = null;
       for(var i = 0; i < max*2; i++) {
-        if(i >= max) {
-          if(i == max) {
-            try {
-              newDb("test_suite_db_" + i, true);
-              T(0 === 1, "Should have failed to create max+1 db's quickly.");
-            } catch(e) {
-              T(e.reason == "all_dbs_active", "All db's should be active.");
-            }
-          }
-          var msecs = (new Date()).getTime() - times[i-max];
-          if(msecs < 1000) {
-            CouchDB.request("GET", "/_sleep?time=" + (msecs+250));
-          }
+        try {
+          db = newDb("test_suite_db_" + i, true);
+        } catch(e) {
+          triggered = true;
+          CouchDB.request("GET", "/_sleep?time=1500");
+          db = newDb("test_suite_db_" + i, true);
         }
-        db = newDb("test_suite_db_" + i, true);
-        times.push((new Date()).getTime());
-        
+
         // Trigger a delayed commit
         db.save({_id: "" + i, "lang": "Awesome!"});
       }
+      T(triggered, "We managed to force a all_dbs_active error.");
       
       var open_dbs = getStat("couchdb", "open_databases").current;
       TEquals(open_dbs > 0, true, "We actually opened some dbs.");

Modified: couchdb/trunk/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_updater.erl?rev=884369&r1=884368&r2=884369&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db_updater.erl Thu Nov 26 02:10:06 2009
@@ -208,7 +208,13 @@
             {noreply, Db}
     end;
 handle_info(delayed_commit, Db) ->
-    {noreply, commit_data(Db)}.
+    case commit_data(Db) of
+        Db ->
+            {noreply, Db};
+        Db2 ->
+            ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
+            {noreply, Db2}
+    end.
 
 code_change(_OldVsn, State, _Extra) ->
     {ok, State}.
@@ -656,10 +662,8 @@
     if OldHeader == Header ->
         Db;
     Delay and (Db#db.waiting_delayed_commit == nil) ->
-        Db2 = Db#db{waiting_delayed_commit=
-                erlang:send_after(1000, self(), delayed_commit)},
-        ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
-        Db2;
+        Db#db{waiting_delayed_commit=
+                erlang:send_after(1000, self(), delayed_commit)};
     Delay ->
         Db;
     true ->
@@ -682,11 +686,9 @@
         _    -> ok
         end,
 
-        Db2 = Db#db{waiting_delayed_commit=nil,
+        Db#db{waiting_delayed_commit=nil,
             header=Header,
-            committed_update_seq=Db#db.update_seq},
-        ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
-        Db2
+            committed_update_seq=Db#db.update_seq}
     end.
 
 



Mime
View raw message