Avoid a race condition for monitored compaction.
It was technically possible for compaction to finish before a monitor
was requested. This fixes that by giving couch_index:compact a third
options parameter that accepts the atom 'monitor' which will then return
{ok, MonRef} instead of a bare ok.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1172378 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/c4d8b423
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/c4d8b423
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/c4d8b423
Branch: refs/heads/import
Commit: c4d8b423b7c0a0cdaa7273b87af249a328218199
Parents: 907e0fb
Author: Paul Joseph Davis <davisp@apache.org>
Authored: Sun Sep 18 21:52:09 2011 +0000
Committer: Paul Joseph Davis <davisp@apache.org>
Committed: Sun Sep 18 21:52:09 2011 +0000
----------------------------------------------------------------------
src/couch_mrview.erl | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/c4d8b423/src/couch_mrview.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview.erl b/src/couch_mrview.erl
index 53a555b..9964d79 100644
--- a/src/couch_mrview.erl
+++ b/src/couch_mrview.erl
@@ -15,7 +15,7 @@
-export([query_all_docs/2, query_all_docs/4]).
-export([query_view/3, query_view/4, query_view/6]).
-export([get_info/2]).
--export([compact/2, monitor_compaction/2, cancel_compaction/2]).
+-export([compact/2, compact/3, cancel_compaction/2]).
-export([cleanup/1]).
-include("couch_db.hrl").
@@ -93,14 +93,12 @@ get_info(Db, DDoc) ->
compact(Db, DDoc) ->
- {ok, Pid} = couch_index_server:get_index(couch_mrview_index, Db, DDoc),
- couch_index:compact(Pid).
+ compact(Db, DDoc, []).
-monitor_compaction(Db, DDoc) ->
- {ok, IPid} = couch_index_server:get_index(couch_mrview_index, Db, DDoc),
- {ok, CPid} = couch_index:get_compactor_pid(IPid),
- couch_index_compactor:monitor(CPid).
+compact(Db, DDoc, Opts) ->
+ {ok, Pid} = couch_index_server:get_index(couch_mrview_index, Db, DDoc),
+ couch_index:compact(Pid, Opts).
cancel_compaction(Db, DDoc) ->
|