summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2012-05-28 15:14:04 -0500
committerRobert Newson <robert.newson@cloudant.com>2012-11-14 17:29:03 +0000
commit5eb7447ad4be97f633cc42432059a67bafcf9009 (patch)
treebfad55674ed6a96552335198e50ffa21334c4730
parentfa43486fbbe918344d66337b3b0b0d34128d5c39 (diff)
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
-rw-r--r--apps/couch/src/couch_proc_manager.erl18
1 files changed, 12 insertions, 6 deletions
diff --git a/apps/couch/src/couch_proc_manager.erl b/apps/couch/src/couch_proc_manager.erl
index ba5dae96..5903c95c 100644
--- a/apps/couch/src/couch_proc_manager.erl
+++ b/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;