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 2009/11/25 23:39:24 UTC
svn commit: r884315 - in /couchdb/trunk: share/www/script/test/stats.js
src/couchdb/couch_db_updater.erl
Author: davisp
Date: Wed Nov 25 22:39:23 2009
New Revision: 884315
URL: http://svn.apache.org/viewvc?rev=884315&view=rev
Log:
Fixed a bug preventing active_dbs from working.
Thanks Jeff Macdonald for the report.
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=884315&r1=884314&r2=884315&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/stats.js (original)
+++ couchdb/trunk/share/www/script/test/stats.js Wed Nov 25 22:39:23 2009
@@ -80,9 +80,24 @@
var testFun = function() {
var pre_dbs = getStat("couchdb", "open_databases").current || 0;
var pre_files = getStat("couchdb", "open_os_files").current || 0;
-
+
+ // We have to make sure that as we open the max'th database
+ // that we've waited for more than 1 second since opening
+ // the first database so that any delayed commits will be
+ // flushed.
+ var times = [];
for(var i = 0; i < max*2; i++) {
- newDb("test_suite_db_" + i, true);
+ if(i >= max) {
+ var msecs = (new Date()).getTime() - times[i-max];
+ if(msecs < 1000) {
+ CouchDB.request("GET", "/_sleep?time=" + (msecs+250));
+ }
+ }
+ db = newDb("test_suite_db_" + i, true);
+ times.push((new Date()).getTime());
+
+ // Trigger a delayed commit
+ db.save({_id: "" + i, "lang": "Awesome!"});
}
var open_dbs = getStat("couchdb", "open_databases").current;
Modified: couchdb/trunk/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_updater.erl?rev=884315&r1=884314&r2=884315&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db_updater.erl Wed Nov 25 22:39:23 2009
@@ -656,8 +656,10 @@
if OldHeader == Header ->
Db;
Delay and (Db#db.waiting_delayed_commit == nil) ->
- Db#db{waiting_delayed_commit=
- erlang:send_after(1000, self(), delayed_commit)};
+ 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;
Delay ->
Db;
true ->
@@ -680,9 +682,11 @@
_ -> ok
end,
- Db#db{waiting_delayed_commit=nil,
+ Db2 = Db#db{waiting_delayed_commit=nil,
header=Header,
- committed_update_seq=Db#db.update_seq}
+ committed_update_seq=Db#db.update_seq},
+ %ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
+ Db2
end.