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 21:08:15 UTC

[couchdb] branch master updated (1deeac0 -> 94f2907)

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

davisp pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    from 1deeac0  fix whitespace crimes
     new b95dbb3  Update couch_native_proc to respect idle timeouts
     new 94f2907  Fix couchdb_os_proc_pool eunit timeouts

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  | 46 +++++++++++++++++++++++++--------
 src/couch/test/couchdb_os_proc_pool.erl |  6 +++--
 2 files changed, 39 insertions(+), 13 deletions(-)

-- 
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 master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit b95dbb33677ca205897bef90669f686fa4473c2a
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 master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 94f2907ea2d75a08f5dd8dae2edbfc6eea5c6bd7
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>.