Author: jchris
Date: Thu Jul  8 19:50:26 2010
New Revision: 961906

URL: http://svn.apache.org/viewvc?rev=961906&view=rev
Log:
Fix for occasional failed tests caused by responding with 202 success to 
compaction requests before the compaction actually begins.

Modified:
    couchdb/branches/0.11.x/src/couchdb/couch_db.erl
    couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl

Modified: couchdb/branches/0.11.x/src/couchdb/couch_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_db.erl?rev=961906&r1=961905&r2=961906&view=diff
==============================================================================
--- couchdb/branches/0.11.x/src/couchdb/couch_db.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_db.erl Thu Jul  8 19:50:26 2010
@@ -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],

Modified: couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl?rev=961906&r1=961905&r2=961906&view=diff
==============================================================================
--- couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl Thu Jul  8 
19:50:26 2010
@@ -133,21 +133,22 @@ handle_call({purge_docs, IdRevs}, _From,
 
     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),


Reply via email to