Permalink
Browse files

Only close idle processes that have no client

Previously we didn't check if an os_process was in use by a process
before closing it. This ended up generating noproc errors in the
couch_view_updaters which would then spider out to the couch_view_group
processes causing client errors and resetting compaction.

BugzId: 13798
  • Loading branch information...
1 parent fa43486 commit 5eb7447ad4be97f633cc42432059a67bafcf9009 @davisp davisp committed with Robert Newson May 28, 2012
Showing with 12 additions and 6 deletions.
  1. +12 −6 apps/couch/src/couch_proc_manager.erl
@@ -89,13 +89,19 @@ handle_call(_Call, _From, State) ->
handle_cast({os_proc_idle, Pid}, #state{tab=Tab}=State) ->
Limit = couch_config:get("query_server_config", "os_process_soft_limit", "100"),
- case ets:info(Tab, size) > list_to_integer(Limit) of
- true ->
- ets:delete(Tab, Pid),
- case is_process_alive(Pid) of
+ case ets:lookup(Tab, Pid) of
+ [#proc{client=nil}] ->
+ case ets:info(Tab, size) > list_to_integer(Limit) of
true ->
- unlink(Pid),
- gen_server:cast(Pid, stop);
+ ?LOG_INFO("Closing idle OS Process: ~p", [Pid]),
+ ets:delete(Tab, Pid),
+ case is_process_alive(Pid) of
+ true ->
+ unlink(Pid),
+ gen_server:cast(Pid, stop);
+ _ ->
+ ok
+ end;
_ ->
ok
end;

0 comments on commit 5eb7447

Please sign in to comment.