Permalink
Browse files

COUCHDB-1444 Fix missing_named_view

Instead of replacing 'EXIT' signals we can just stuff the process that
exited into the exit reason and match on that.
  • Loading branch information...
davisp committed Aug 15, 2012
1 parent a28110f commit b59ac98b4be8d8c9e3f1114dd0a785f0f4dd30d1
Showing with 7 additions and 6 deletions.
  1. +5 −4 src/couch_index/src/couch_index_updater.erl
  2. +2 −2 src/couch_mrview/src/couch_mrview_compactor.erl
@@ -86,12 +86,13 @@ handle_cast(_Mesg, State) ->
{stop, unknown_cast, State}.
-handle_info({'EXIT', Pid, {updated, IdxState}}, #st{mod=Mod, pid=Pid}=State) ->
+handle_info({'EXIT', _, {updated, Pid, IdxState}}, #st{pid=Pid}=State) ->
+ Mod = State#st.mod,
Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
?LOG_INFO("Index update finished for db: ~s idx: ~s", Args),
ok = gen_server:cast(State#st.idx, {updated, IdxState}),
{noreply, State#st{pid=undefined}};
-handle_info({'EXIT', Pid, reset}, #st{idx=Idx, pid=Pid}=State) ->
+handle_info({'EXIT', _, {reset, Pid}}, #st{idx=Idx, pid=Pid}=State) ->
{ok, NewIdxState} = gen_server:call(State#st.idx, reset),
Pid2 = spawn_link(fun() -> update(Idx, State#st.mod, NewIdxState) end),
{noreply, State#st{pid=Pid2}};
@@ -131,7 +132,7 @@ update(Idx, Mod, IdxState) ->
PurgedIdxState = case purge_index(Db, Mod, IdxState) of
{ok, IdxState0} -> IdxState0;
- reset -> exit(reset)
+ reset -> exit({reset, self()})
end,
NumChanges = couch_db:count_changes_since(Db, CurrSeq),
@@ -181,7 +182,7 @@ update(Idx, Mod, IdxState) ->
end,
{ok, FinalIdxState} = Mod:finish_update(LastIdxSt),
- exit({updated, FinalIdxState})
+ exit({updated, self(), FinalIdxState})
end).
@@ -116,11 +116,11 @@ compact(State) ->
recompact(State) ->
link(State#mrst.fd),
- {_Pid, Ref} = erlang:spawn_monitor(fun() ->
+ {Pid, Ref} = erlang:spawn_monitor(fun() ->
couch_index_updater:update(couch_mrview_index, State)
end),
receive
- {'DOWN', Ref, _, _, {updated, State2}} ->
+ {'DOWN', Ref, _, _, {updated, Pid, State2}} ->
unlink(State#mrst.fd),
{ok, State2}
end.

0 comments on commit b59ac98

Please sign in to comment.