You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2026/07/16 13:59:24 UTC

(couchdb) branch main updated (803542b6d -> 2eed4886d)

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

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


    from 803542b6d docs: make Figure 6 revision label readable
     new d4067c4f9 feat(couch): add process_count gauge to query server manager
     new 2eed4886d sq - update gauge in dec_count and inc_count

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/priv/stats_descriptions.cfg | 4 ++++
 src/couch/src/couch_proc_manager.erl  | 4 ++++
 2 files changed, 8 insertions(+)


(couchdb) 01/02: feat(couch): add process_count gauge to query server manager

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

nickva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d4067c4f9274b93a0f07dda6c5f75ab451858bcd
Author: Sam Smith <sa...@samsmith.xyz>
AuthorDate: Wed Jul 15 15:47:01 2026 +0100

    feat(couch): add process_count gauge to query server manager
    
    Track the number of active query server processes to provide
    visibility into resource usage. The gauge is updated when processes
    spawn/remove.
---
 src/couch/priv/stats_descriptions.cfg | 4 ++++
 src/couch/src/couch_proc_manager.erl  | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/couch/priv/stats_descriptions.cfg b/src/couch/priv/stats_descriptions.cfg
index 17f028782..3497b728b 100644
--- a/src/couch/priv/stats_descriptions.cfg
+++ b/src/couch/priv/stats_descriptions.cfg
@@ -322,6 +322,10 @@
     {type, counter},
     {desc, <<"number of acquired external processes">>}
 ]}.
+{[couchdb, query_server, process_count], [
+    {type, gauge},
+    {desc, <<"number of active query server processes">>}
+]}.
 {[couchdb, query_server, process_starts], [
     {type, counter},
     {desc, <<"number of OS process starts">>}
diff --git a/src/couch/src/couch_proc_manager.erl b/src/couch/src/couch_proc_manager.erl
index ea4a76001..a95acc7c0 100644
--- a/src/couch/src/couch_proc_manager.erl
+++ b/src/couch/src/couch_proc_manager.erl
@@ -141,6 +141,8 @@ init([]) ->
 
     ok = configure_language_servers(),
 
+    couch_stats:update_gauge([couchdb, query_server, process_count], get_proc_count()),
+
     {ok, #state{
         config = get_proc_config(),
         threshold_ts = timestamp(),
@@ -250,6 +252,7 @@ handle_info({'EXIT', Pid, spawn_error}, State) ->
     % Assert when removing that we always expect the opener to have been there
     [{Pid, #client{lang = Lang}}] = ets:take(?OPENING, Pid),
     dec_count(Lang),
+    couch_stats:update_gauge([couchdb, query_server, process_count], get_proc_count()),
     ok = flush_waiters(State, Lang),
     {noreply, State};
 handle_info({'EXIT', Pid, Reason}, State) ->
@@ -370,7 +373,8 @@ find_proc(Lang, DbPat, DDocKey) when
 spawn_proc(#client{} = Client) ->
     Pid = spawn_link(?MODULE, new_proc, [Client]),
     ets:insert(?OPENING, {Pid, Client}),
-    inc_count(Client#client.lang).
+    inc_count(Client#client.lang),
+    couch_stats:update_gauge([couchdb, query_server, process_count], get_proc_count()).
 
 % This instance was spawned without a client to replenish
 % the untagged pool asynchronously
@@ -686,7 +690,8 @@ remove_proc(#proc{pid = Pid} = Proc) ->
         false ->
             ok
     end,
-    dec_count(Proc#proc.lang).
+    dec_count(Proc#proc.lang),
+    couch_stats:update_gauge([couchdb, query_server, process_count], get_proc_count()).
 
 flush_waiters(#state{} = State, Lang) ->
     #state{hard_limit = HardLimit, config = {[_ | _] = Cfg}} = State,


(couchdb) 02/02: sq - update gauge in dec_count and inc_count

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

nickva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 2eed4886d1853b97459ffd4f0c827e0cdd816a91
Author: Sam Smith <sa...@samsmith.xyz>
AuthorDate: Thu Jul 16 10:48:35 2026 +0100

    sq - update gauge in dec_count and inc_count
---
 src/couch/src/couch_proc_manager.erl | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/couch/src/couch_proc_manager.erl b/src/couch/src/couch_proc_manager.erl
index a95acc7c0..20ed2d50d 100644
--- a/src/couch/src/couch_proc_manager.erl
+++ b/src/couch/src/couch_proc_manager.erl
@@ -252,7 +252,6 @@ handle_info({'EXIT', Pid, spawn_error}, State) ->
     % Assert when removing that we always expect the opener to have been there
     [{Pid, #client{lang = Lang}}] = ets:take(?OPENING, Pid),
     dec_count(Lang),
-    couch_stats:update_gauge([couchdb, query_server, process_count], get_proc_count()),
     ok = flush_waiters(State, Lang),
     {noreply, State};
 handle_info({'EXIT', Pid, Reason}, State) ->
@@ -373,8 +372,7 @@ find_proc(Lang, DbPat, DDocKey) when
 spawn_proc(#client{} = Client) ->
     Pid = spawn_link(?MODULE, new_proc, [Client]),
     ets:insert(?OPENING, {Pid, Client}),
-    inc_count(Client#client.lang),
-    couch_stats:update_gauge([couchdb, query_server, process_count], get_proc_count()).
+    inc_count(Client#client.lang).
 
 % This instance was spawned without a client to replenish
 % the untagged pool asynchronously
@@ -690,8 +688,7 @@ remove_proc(#proc{pid = Pid} = Proc) ->
         false ->
             ok
     end,
-    dec_count(Proc#proc.lang),
-    couch_stats:update_gauge([couchdb, query_server, process_count], get_proc_count()).
+    dec_count(Proc#proc.lang).
 
 flush_waiters(#state{} = State, Lang) ->
     #state{hard_limit = HardLimit, config = {[_ | _] = Cfg}} = State,
@@ -803,10 +800,12 @@ foreach_proc(Fun) when is_function(Fun, 1) ->
 
 inc_count(Lang) ->
     ets:update_counter(?COUNTERS, Lang, 1, {Lang, 0}),
+    couch_stats:update_gauge([couchdb, query_server, process_count], get_proc_count()),
     ok.
 
 dec_count(Lang) ->
     ets:update_counter(?COUNTERS, Lang, -1, {Lang, 0}),
+    couch_stats:update_gauge([couchdb, query_server, process_count], get_proc_count()),
     ok.
 
 get_count(Lang) ->