couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject [44/50] git commit: Keep the databae open for index compaction.
Date Wed, 26 Oct 2011 18:05:33 GMT
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



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1173435 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/40f345c5
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/40f345c5
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/40f345c5

Branch: refs/heads/1319-large-headers-are-corrupted
Commit: 40f345c530b2383b18ca99385d29d6a0ed30ff59
Parents: ad85883
Author: Paul Joseph Davis <davisp@apache.org>
Authored: Wed Sep 21 00:14:25 2011 +0000
Committer: Paul Joseph Davis <davisp@apache.org>
Committed: Wed Sep 21 00:14:25 2011 +0000

----------------------------------------------------------------------
 src/couch_index/src/couch_index_compactor.erl   |    7 +++++--
 src/couch_mrview/src/couch_mrview_compactor.erl |    4 ++--
 src/couch_mrview/src/couch_mrview_index.erl     |    6 +++---
 3 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/40f345c5/src/couch_index/src/couch_index_compactor.erl
----------------------------------------------------------------------
diff --git a/src/couch_index/src/couch_index_compactor.erl b/src/couch_index/src/couch_index_compactor.erl
index d0bd96c..b8b1ecc 100644
--- a/src/couch_index/src/couch_index_compactor.erl
+++ b/src/couch_index/src/couch_index_compactor.erl
@@ -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),

http://git-wip-us.apache.org/repos/asf/couchdb/blob/40f345c5/src/couch_mrview/src/couch_mrview_compactor.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview/src/couch_mrview_compactor.erl b/src/couch_mrview/src/couch_mrview_compactor.erl
index 989b234..cf3cf22 100644
--- a/src/couch_mrview/src/couch_mrview_compactor.erl
+++ b/src/couch_mrview/src/couch_mrview_compactor.erl
@@ -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)

http://git-wip-us.apache.org/repos/asf/couchdb/blob/40f345c5/src/couch_mrview/src/couch_mrview_index.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview/src/couch_mrview_index.erl b/src/couch_mrview/src/couch_mrview_index.erl
index 8fca96a..a604651 100644
--- a/src/couch_mrview/src/couch_mrview_index.erl
+++ b/src/couch_mrview/src/couch_mrview_index.erl
@@ -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