From 72675d73f8e571b1a5555451f5c588225a157035 Mon Sep 17 00:00:00 2001 From: Paul Joseph Davis Date: Sat, 31 Oct 2009 01:17:04 +0000 Subject: List functions weren't returning OS processes. Needed to add a call to couch_query_server:stop_map_doc/1 to return outstanding OS processes back to the query servers pools. This was causing some awesome errors by keeping the query_servers PID linked to the socket PID, which caused errors in apparently unrelated requests as the query_servers daemon was restarted on config changes. Also needed to move where the query servers were requested in list functions involving reduces. Map only lists were fine though. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@831502 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd_show.erl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/couchdb/couch_httpd_show.erl b/src/couchdb/couch_httpd_show.erl index fe8e2002..4ed11c2a 100644 --- a/src/couchdb/couch_httpd_show.erl +++ b/src/couchdb/couch_httpd_show.erl @@ -286,14 +286,14 @@ output_reduce_list(#httpd{mochi_req=MReq, user_ctx=UserCtx}=Req, Lang, ListSrc, skip = SkipCount, group_level = GroupLevel } = QueryArgs, - % get the os process here - % pass it into the view fold with closures - {ok, QueryServer} = couch_query_servers:start_view_list(Lang, ListSrc), Headers = MReq:get(headers), Hlist = mochiweb_headers:to_list(Headers), Accept = proplists:get_value('Accept', Hlist), CurrentEtag = couch_httpd_view:view_group_etag(Group, Db, {Lang, ListSrc, Accept, UserCtx}), couch_httpd:etag_respond(Req, CurrentEtag, fun() -> + % get the os process here + % pass it into the view fold with closures + {ok, QueryServer} = couch_query_servers:start_view_list(Lang, ListSrc), StartListRespFun = make_reduce_start_resp_fun(QueryServer, Req, Db, CurrentEtag), SendListRowFun = make_reduce_send_row_fun(QueryServer, Db), @@ -316,14 +316,14 @@ output_reduce_list(#httpd{mochi_req=MReq, user_ctx=UserCtx}=Req, Lang, ListSrc, skip = SkipCount, group_level = GroupLevel } = QueryArgs, - % get the os process here - % pass it into the view fold with closures - {ok, QueryServer} = couch_query_servers:start_view_list(Lang, ListSrc), Headers = MReq:get(headers), Hlist = mochiweb_headers:to_list(Headers), Accept = proplists:get_value('Accept', Hlist), CurrentEtag = couch_httpd_view:view_group_etag(Group, Db, {Lang, ListSrc, Accept, UserCtx, Keys}), couch_httpd:etag_respond(Req, CurrentEtag, fun() -> + % get the os process here + % pass it into the view fold with closures + {ok, QueryServer} = couch_query_servers:start_view_list(Lang, ListSrc), StartListRespFun = make_reduce_start_resp_fun(QueryServer, Req, Db, CurrentEtag), SendListRowFun = make_reduce_send_row_fun(QueryServer, Db), @@ -365,6 +365,7 @@ finish_list(Req, QueryServer, Etag, FoldResult, StartFun, TotalRows) -> [<<"end">>, Chunks] = couch_query_servers:render_list_tail(QueryServer), send_non_empty_chunk(Resp, ?b2l(?l2b(Chunks))) end, + couch_query_servers:stop_doc_map(QueryServer), last_chunk(Resp). -- cgit v1.2.3