summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2012-12-02 09:04:48 -0500
committerAdam Kocoloski <kocolosk@apache.org>2012-12-05 15:41:05 -0800
commite64bbecd01f054761ff77fa6f921b50aa1d5803d (patch)
tree1ac4935b42a46fe3ebd55e825480a536d0adacca
parenta606463249e75e9a6184447dec84ee26ed74bc0c (diff)
downloadcouchdb-e64bbecd01f054761ff77fa6f921b50aa1d5803d.tar.gz
Close view files cleanly on DB create/delete
The shutdown_sync was actually interfering with a clean shutdown initiated by the index processes themselves when they received a 'DOWN' message from their monitoring of the DB process. The explicit 'delete' cast message in this patch is very probably redundant, but it makes the intent clear. The important bit is to let the index process terminate *and* get confirmation of the termination before attempting to nuke the directory. COUCHDB-1364
-rw-r--r--src/couch_index/src/couch_index_server.erl4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/couch_index/src/couch_index_server.erl b/src/couch_index/src/couch_index_server.erl
index 48fa8e42e..bc1fce77c 100644
--- a/src/couch_index/src/couch_index_server.erl
+++ b/src/couch_index/src/couch_index_server.erl
@@ -160,7 +160,9 @@ reset_indexes(DbName, Root) ->
% shutdown all the updaters and clear the files, the db got changed
Fun = fun({_, {DDocId, Sig}}) ->
[{_, Pid}] = ets:lookup(?BY_SIG, {DbName, Sig}),
- couch_util:shutdown_sync(Pid),
+ MRef = erlang:monitor(process, Pid),
+ gen_server:cast(Pid, delete),
+ receive {'DOWN', MRef, _, _, _} -> ok end,
rem_from_ets(DbName, Sig, DDocId, Pid)
end,
lists:foreach(Fun, ets:lookup(?BY_DB, DbName)),