summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2010-07-08 14:54:29 +0000
committerDamien F. Katz <damien@apache.org>2010-07-08 14:54:29 +0000
commitddd9811edb767d6ca9ba77ce6ae1eedffac6a8ca (patch)
treeaf207a665effac27bf160ac83216942e67ee15ac /src/couchdb
parentb458999a36785410d7a45b5d4cb5bea2d5638994 (diff)
Fix for occasional failed tests caused by responding with 202 success to compaction requests before the compaction actually begins.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@961791 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_db.erl2
-rw-r--r--src/couchdb/couch_db_updater.erl15
2 files changed, 9 insertions, 8 deletions
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index cf25dc62..80f0d7bf 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -103,7 +103,7 @@ monitor(#db{main_pid=MainPid}) ->
erlang:monitor(process, MainPid).
start_compact(#db{update_pid=Pid}) ->
- gen_server:cast(Pid, start_compact).
+ gen_server:call(Pid, start_compact).
delete_doc(Db, Id, Revisions) ->
DeletedDocs = [#doc{id=Id, revs=[Rev], deleted=true} || Rev <- Revisions],
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index 30275012..f0879700 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -143,21 +143,22 @@ handle_call({purge_docs, IdRevs}, _From, Db) ->
ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
couch_db_update_notifier:notify({updated, Db#db.name}),
- {reply, {ok, (Db2#db.header)#db_header.purge_seq, IdRevsPurged}, Db2}.
-
-
-handle_cast(start_compact, Db) ->
+ {reply, {ok, (Db2#db.header)#db_header.purge_seq, IdRevsPurged}, Db2};
+handle_call(start_compact, _From, Db) ->
case Db#db.compactor_pid of
nil ->
?LOG_INFO("Starting compaction for db \"~s\"", [Db#db.name]),
Pid = spawn_link(fun() -> start_copy_compact(Db) end),
Db2 = Db#db{compactor_pid=Pid},
ok = gen_server:call(Db#db.main_pid, {db_updated, Db2}),
- {noreply, Db2};
+ {reply, ok, Db2};
_ ->
% compact currently running, this is a no-op
- {noreply, Db}
- end;
+ {reply, ok, Db}
+ end.
+
+
+
handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) ->
{ok, NewFd} = couch_file:open(CompactFilepath),
{ok, NewHeader} = couch_file:read_header(NewFd),