couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1165433 - in /couchdb/trunk: src/couchdb/couch_compaction_daemon.erl src/couchdb/couch_db.erl test/etap/220-compaction-daemon.t
Date Mon, 05 Sep 2011 21:57:46 GMT
Author: fdmanana
Date: Mon Sep  5 21:57:45 2011
New Revision: 1165433

URL: http://svn.apache.org/viewvc?rev=1165433&view=rev
Log:
Close database if database compaction is not done

Issue found, and patch, by Mike Leddy. Patch extended
with a test. Thanks Mike.

Modified:
    couchdb/trunk/src/couchdb/couch_compaction_daemon.erl
    couchdb/trunk/src/couchdb/couch_db.erl
    couchdb/trunk/test/etap/220-compaction-daemon.t

Modified: couchdb/trunk/src/couchdb/couch_compaction_daemon.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_compaction_daemon.erl?rev=1165433&r1=1165432&r2=1165433&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_compaction_daemon.erl (original)
+++ couchdb/trunk/src/couchdb/couch_compaction_daemon.erl Mon Sep  5 21:57:45 2011
@@ -185,6 +185,7 @@ maybe_compact_db(DbName, Config) ->
                 end
             end;
         false ->
+            couch_db:close(Db),
             maybe_compact_views(DbName, DDocNames, Config)
         end;
     _ ->

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=1165433&r1=1165432&r2=1165433&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Mon Sep  5 21:57:45 2011
@@ -110,6 +110,8 @@ close(#db{fd_ref_counter=RefCntr}) ->
 open_ref_counted(MainPid, OpenedPid) ->
     gen_server:call(MainPid, {open_ref_count, OpenedPid}).
 
+is_idle(#db{main_pid = MainPid}) ->
+    is_idle(MainPid);
 is_idle(MainPid) ->
     gen_server:call(MainPid, is_idle).
 

Modified: couchdb/trunk/test/etap/220-compaction-daemon.t
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/etap/220-compaction-daemon.t?rev=1165433&r1=1165432&r2=1165433&view=diff
==============================================================================
--- couchdb/trunk/test/etap/220-compaction-daemon.t (original)
+++ couchdb/trunk/test/etap/220-compaction-daemon.t Mon Sep  5 21:57:45 2011
@@ -25,7 +25,7 @@ test_db_name() ->
 main(_) ->
     test_util:init_code_path(),
 
-    etap:plan(8),
+    etap:plan(10),
     case (catch test()) of
         ok ->
             etap:end_tests();
@@ -76,6 +76,7 @@ test() ->
 
     disable_compact_daemon(),
     ok = timer:sleep(6000), % 2 times check_interval
+    etap:is(couch_db:is_idle(Db), true, "Database is idle"),
     populate(70, 70, 200 * 1024),
     {_, DbFileSize3} = get_db_frag(),
     {_, ViewFileSize3} = get_view_frag(),
@@ -98,6 +99,9 @@ test() ->
     etap:is(true, (DbFileSize4 < DbFileSize3), "Database file size decreased again"),
     etap:is(true, (ViewFileSize4 < ViewFileSize3), "View file size decreased again"),
 
+    ok = timer:sleep(6000), % 2 times check_interval
+    etap:is(couch_db:is_idle(Db), true, "Database is idle"),
+
     delete_db(),
     couch_server_sup:stop(),
     ok.



Mime
View raw message