couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1173435 - in /couchdb/trunk/src: couch_index/src/couch_index_compactor.erl couch_mrview/src/couch_mrview_compactor.erl couch_mrview/src/couch_mrview_index.erl
Date Wed, 21 Sep 2011 00:14:25 GMT
Author: davisp
Date: Wed Sep 21 00:14:25 2011
New Revision: 1173435

URL: http://svn.apache.org/viewvc?rev=1173435&view=rev
Log:
Keep the databae open for index compaction.

Long running index compactions could fail to complete if something was
iterating db's due to the underlying db being closed. Seeing as index
compaction is non-resumable this prevented index compaction from
completing.

Fixes COUCHDB-1283


Modified:
    couchdb/trunk/src/couch_index/src/couch_index_compactor.erl
    couchdb/trunk/src/couch_mrview/src/couch_mrview_compactor.erl
    couchdb/trunk/src/couch_mrview/src/couch_mrview_index.erl

Modified: couchdb/trunk/src/couch_index/src/couch_index_compactor.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couch_index/src/couch_index_compactor.erl?rev=1173435&r1=1173434&r2=1173435&view=diff
==============================================================================
--- couchdb/trunk/src/couch_index/src/couch_index_compactor.erl (original)
+++ couchdb/trunk/src/couch_index/src/couch_index_compactor.erl Wed Sep 21 00:14:25 2011
@@ -97,9 +97,12 @@ compact(Parent, Mod, IdxState) ->
     compact(Parent, Mod, IdxState, []).
 
 compact(Idx, Mod, IdxState, Opts) ->
-    Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
+    DbName = Mod:get(db_name, IdxState),
+    Args = [DbName, Mod:get(idx_name, IdxState)],
     ?LOG_INFO("Compaction started for db: ~s idx: ~s", Args),
-    {ok, NewIdxState} = Mod:compact(IdxState, Opts),
+    {ok, NewIdxState} = couch_util:with_db(DbName, fun(Db) ->
+        Mod:compact(Db, IdxState, Opts)
+    end),
     case gen_server:call(Idx, {compacted, NewIdxState}) of
         recompact ->
             ?LOG_INFO("Compaction restarting for db: ~s idx: ~s", Args),

Modified: couchdb/trunk/src/couch_mrview/src/couch_mrview_compactor.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couch_mrview/src/couch_mrview_compactor.erl?rev=1173435&r1=1173434&r2=1173435&view=diff
==============================================================================
--- couchdb/trunk/src/couch_mrview/src/couch_mrview_compactor.erl (original)
+++ couchdb/trunk/src/couch_mrview/src/couch_mrview_compactor.erl Wed Sep 21 00:14:25 2011
@@ -15,7 +15,7 @@
 -include("couch_db.hrl").
 -include_lib("couch_mrview/include/couch_mrview.hrl").
 
--export([compact/2, swap_compacted/2]).
+-export([compact/3, swap_compacted/2]).
 
 -record(acc, {
    btree = nil,
@@ -27,7 +27,7 @@
 }).
 
 
-compact(State, Opts) ->
+compact(_Db, State, Opts) ->
     case lists:member(recompact, Opts) of
         false -> compact(State);
         true -> recompact(State)

Modified: couchdb/trunk/src/couch_mrview/src/couch_mrview_index.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couch_mrview/src/couch_mrview_index.erl?rev=1173435&r1=1173434&r2=1173435&view=diff
==============================================================================
--- couchdb/trunk/src/couch_mrview/src/couch_mrview_index.erl (original)
+++ couchdb/trunk/src/couch_mrview/src/couch_mrview_index.erl Wed Sep 21 00:14:25 2011
@@ -16,7 +16,7 @@
 -export([get/2]).
 -export([init/2, open/2, close/1, reset/1, delete/1]).
 -export([start_update/3, purge/4, process_doc/3, finish_update/1, commit/1]).
--export([compact/2, swap_compacted/2]).
+-export([compact/3, swap_compacted/2]).
 
 
 -include_lib("couch_mrview/include/couch_mrview.hrl").
@@ -131,8 +131,8 @@ commit(State) ->
     couch_file:write_header(State#mrst.fd, Header).
 
 
-compact(State, Opts) ->
-    couch_mrview_compactor:compact(State, Opts).
+compact(Db, State, Opts) ->
+    couch_mrview_compactor:compact(Db, State, Opts).
 
 
 swap_compacted(OldState, NewState) ->



Mime
View raw message