From 5eb7447ad4be97f633cc42432059a67bafcf9009 Mon Sep 17 00:00:00 2001 From: "Paul J. Davis" Date: Mon, 28 May 2012 15:14:04 -0500 Subject: 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 --- apps/couch/src/couch_proc_manager.erl | 18 ++++++++++++------ 1 file 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; -- cgit v1.2.3