From f5d752a3c5f1c05962a7b693b54636967bfa7a5d Mon Sep 17 00:00:00 2001 From: "Damien F. Katz" Date: Mon, 27 Apr 2009 19:08:33 +0000 Subject: Fix and test for COUCHDB-334 where a database with delayed commits pending is considered idle, and subject to losing changes when shutdown git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@769109 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/delayed_commits.js | 22 ++++++++++++++++++++++ src/couchdb/couch_db.erl | 6 +++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/share/www/script/test/delayed_commits.js b/share/www/script/test/delayed_commits.js index daebdb8d..0ead2d84 100644 --- a/share/www/script/test/delayed_commits.js +++ b/share/www/script/test/delayed_commits.js @@ -90,4 +90,26 @@ couchTests.delayed_commits = function(debug) { 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 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 -- cgit v1.2.3