You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2017/07/12 19:19:52 UTC

[couchdb] branch 631-fix-os-proc-pool-eunit updated (34c5b71 -> 49f6873)

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to branch 631-fix-os-proc-pool-eunit
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    omit 34c5b71  Fix couchdb_os_proc_pool eunit timeouts
    omit 471d6fe  Update couch_native_proc to respect idle timeouts
     new c5df3b4  Update couch_native_proc to respect idle timeouts
     new 49f6873  Fix couchdb_os_proc_pool eunit timeouts

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (34c5b71)
            \
             N -- N -- N   refs/heads/631-fix-os-proc-pool-eunit (49f6873)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/couch/src/couch_native_process.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].

[couchdb] 01/02: Update couch_native_proc to respect idle timeouts

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch 631-fix-os-proc-pool-eunit
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit c5df3b47c65d996f0aa4d7ff6c41651eb50ca463
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Jul 12 13:54:37 2017 -0500

    Update couch_native_proc to respect idle timeouts
---
 src/couch/src/couch_native_process.erl | 46 ++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/src/couch/src/couch_native_process.erl b/src/couch/src/couch_native_process.erl
index ab279cd..7f6ea7d 100644
--- a/src/couch/src/couch_native_process.erl
+++ b/src/couch/src/couch_native_process.erl
@@ -46,7 +46,14 @@
 -export([set_timeout/2, prompt/2]).
 
 -define(STATE, native_proc_state).
--record(evstate, {ddocs, funs=[], query_config=[], list_pid=nil, timeout=5000}).
+-record(evstate, {
+    ddocs,
+    funs = [],
+    query_config = [],
+    list_pid = nil,
+    timeout = 5000,
+    idle = 5000
+}).
 
 -include_lib("couch/include/couch_db.hrl").
 
@@ -65,10 +72,12 @@ prompt(Pid, Data) when is_list(Data) ->
 
 % gen_server callbacks
 init([]) ->
-    {ok, #evstate{ddocs=dict:new()}}.
+    V = config:get("query_server_config", "os_process_idle_limit", "300"),
+    Idle = list_to_integer(V) * 1000,
+    {ok, #evstate{ddocs=dict:new(), idle=Idle}, Idle}.
 
 handle_call({set_timeout, TimeOut}, _From, State) ->
-    {reply, ok, State#evstate{timeout=TimeOut}};
+    {reply, ok, State#evstate{timeout=TimeOut}, State#evstate.idle};
 
 handle_call({prompt, Data}, _From, State) ->
     couch_log:debug("Prompt native qs: ~s",[?JSON_ENCODE(Data)]),
@@ -79,28 +88,38 @@ handle_call({prompt, Data}, _From, State) ->
                 {State, [<<"error">>, Why, Why]}
         end,
 
+    Idle = State#evstate.idle,
     case Resp of
         {error, Reason} ->
             Msg = io_lib:format("couch native server error: ~p", [Reason]),
-            {reply, [<<"error">>, <<"native_query_server">>, list_to_binary(Msg)], NewState};
+            Error = [<<"error">>, <<"native_query_server">>, list_to_binary(Msg)],
+            {reply, Error, NewState, Idle};
         [<<"error">> | Rest] ->
             % Msg = io_lib:format("couch native server error: ~p", [Rest]),
             % TODO: markh? (jan)
-            {reply, [<<"error">> | Rest], NewState};
+            {reply, [<<"error">> | Rest], NewState, Idle};
         [<<"fatal">> | Rest] ->
             % Msg = io_lib:format("couch native server error: ~p", [Rest]),
             % TODO: markh? (jan)
             {stop, fatal, [<<"error">> | Rest], NewState};
         Resp ->
-            {reply, Resp, NewState}
+            {reply, Resp, NewState, Idle}
     end.
 
 handle_cast(garbage_collect, State) ->
     erlang:garbage_collect(),
-    {noreply, State};
-handle_cast(_, State) -> {noreply, State}.
+    {noreply, State, State#evstate.idle};
+handle_cast(stop, State) ->
+    {stop, normal, State};
+handle_cast(_Msg, State) ->
+    {noreply, State, State#evstate.idle}.
 
-handle_info({'EXIT',_,normal}, State) -> {noreply, State};
+handle_info(timeout, State) ->
+    gen_server:cast(couch_proc_manager, {os_proc_idle, self()}),
+    erlang:garbage_collect(),
+    {noreply, State, State#evstate.idle};
+handle_info({'EXIT',_,normal}, State) ->
+    {noreply, State, State#evstate.idle};
 handle_info({'EXIT',_,Reason}, State) ->
     {stop, Reason, State}.
 terminate(_Reason, _State) -> ok.
@@ -142,8 +161,13 @@ run(#evstate{list_pid=Pid}=State, _Command) when is_pid(Pid) ->
     {State, [<<"error">>, list_error, list_error]};
 run(#evstate{ddocs=DDocs}, [<<"reset">>]) ->
     {#evstate{ddocs=DDocs}, true};
-run(#evstate{ddocs=DDocs}, [<<"reset">>, QueryConfig]) ->
-    {#evstate{ddocs=DDocs, query_config=QueryConfig}, true};
+run(#evstate{ddocs=DDocs, idle=Idle}, [<<"reset">>, QueryConfig]) ->
+    NewState = #evstate{
+        ddocs = DDocs,
+        query_config = QueryConfig,
+        idle = Idle
+    },
+    {NewState, true};
 run(#evstate{funs=Funs}=State, [<<"add_fun">> , BinFunc]) ->
     FunInfo = makefun(State, BinFunc),
     {State#evstate{funs=Funs ++ [FunInfo]}, true};

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.

[couchdb] 02/02: Fix couchdb_os_proc_pool eunit timeouts

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch 631-fix-os-proc-pool-eunit
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 49f6873db9567107582ad6da523835ebfcc02010
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Jul 12 13:56:08 2017 -0500

    Fix couchdb_os_proc_pool eunit timeouts
    
    There's a theory that the low memory limits on our CI instances are
    causing the tests spawning JS processes to fail. Given that we don't
    need them here we can trivially exclude that as a cause of the test
    failures.
    
    Fixes #631
---
 src/couch/test/couchdb_os_proc_pool.erl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/couch/test/couchdb_os_proc_pool.erl b/src/couch/test/couchdb_os_proc_pool.erl
index f14af68..65ae5c5 100644
--- a/src/couch/test/couchdb_os_proc_pool.erl
+++ b/src/couch/test/couchdb_os_proc_pool.erl
@@ -206,6 +206,8 @@ should_reduce_pool_on_idle_os_procs() ->
 
 
 setup_config() ->
+    MFA = "{couch_native_process, start_link, []}",
+    config:set("native_query_servers", "test_lang", MFA, false),
     config:set("query_server_config", "os_process_limit", "3", false),
     config:set("query_server_config", "os_process_soft_limit", "2", false),
     ok = confirm_config("os_process_soft_limit", "2").
@@ -233,7 +235,7 @@ spawn_client() ->
     Parent = self(),
     Ref = make_ref(),
     Pid = spawn(fun() ->
-        Proc = couch_query_servers:get_os_process(<<"javascript">>),
+        Proc = couch_query_servers:get_os_process(<<"test_lang">>),
         loop(Parent, Ref, Proc)
     end),
     {Pid, Ref}.
@@ -243,7 +245,7 @@ spawn_client(DDocId) ->
     Ref = make_ref(),
     Pid = spawn(fun() ->
         DDocKey = {DDocId, <<"1-abcdefgh">>},
-        DDoc = #doc{body={[]}},
+        DDoc = #doc{body={[{<<"language">>, <<"test_lang">>}]}},
         Proc = couch_query_servers:get_ddoc_process(DDoc, DDocKey),
         loop(Parent, Ref, Proc)
     end),

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.