You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/01/17 23:10:10 UTC
[25/49] git commit: COUCHDB-1444 Fix missing_named_view errors
COUCHDB-1444 Fix missing_named_view errors
Relying on exit signals we were accidentally replacing view state
incorrectly when an exit signal accidentally spidered between various
processes related to couch_os_processes. This changes the state updates
to be a '$gen_cast' instead.
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/a97a3245
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/a97a3245
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/a97a3245
Branch: refs/heads/import
Commit: a97a3245aae549041b3e3fd42502380c483daa29
Parents: 4386d42
Author: Paul Joseph Davis <da...@apache.org>
Authored: Fri Aug 10 10:45:03 2012 -0500
Committer: Paul Joseph Davis <da...@apache.org>
Committed: Tue Aug 14 16:29:57 2012 -0500
----------------------------------------------------------------------
src/couch_mrview_compactor.erl | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/a97a3245/src/couch_mrview_compactor.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_compactor.erl b/src/couch_mrview_compactor.erl
index cf3cf22..38257bf 100644
--- a/src/couch_mrview_compactor.erl
+++ b/src/couch_mrview_compactor.erl
@@ -115,14 +115,25 @@ compact(State) ->
recompact(State) ->
+ Self = self(),
link(State#mrst.fd),
- {_Pid, Ref} = erlang:spawn_monitor(fun() ->
- couch_index_updater:update(couch_mrview_index, State)
+ {Pid, Ref} = erlang:spawn_monitor(fun() ->
+ couch_index_updater:update(Self, couch_mrview_index, State)
end),
+ State2 = wait_for_recompact(Pid, Ref),
+ erlang:demonitor(Ref, [flush]),
+ unlink(State#mrst.fd),
+ {ok, State2}.
+
+
+wait_for_recompact(Pid, Ref) ->
receive
- {'DOWN', Ref, _, _, {updated, State2}} ->
- unlink(State#mrst.fd),
- {ok, State2}
+ {'$gen_cast', {Pid, updated, State}} ->
+ State;
+ {'$gen_cast', {new_state, _}} ->
+ wait_for_recompact(Pid, Ref);
+ {'DOWN', Ref, _, _, Reason} ->
+ erlang:error({couch_mrview_compact_error, Reason})
end.