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 2024/07/22 20:52:49 UTC
(couchdb) branch add-client-monitor-to-dreyfus updated (e1edc8aa1 -> eceb46653)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch add-client-monitor-to-dreyfus
in repository https://gitbox.apache.org/repos/asf/couchdb.git
discard e1edc8aa1 Add passively closed client monitoring to search
new eceb46653 Add passively closed client monitoring to search
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 (e1edc8aa1)
\
N -- N -- N refs/heads/add-client-monitor-to-dreyfus (eceb46653)
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 1 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:
(couchdb) 01/01: Add passively closed client monitoring to search
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch add-client-monitor-to-dreyfus
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit eceb46653b2bd3d3d4649e503fbd4e2c06734a3b
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Mon Jul 22 16:43:00 2024 -0400
Add passively closed client monitoring to search
We added client monitoring [1] for streaming fabric requests (_all_docs,
_change, etc), but never added them to dreyfus since it's not using the streams
abstraction.
Add client monitoring to dreyfus but exporting a few internal functions from
`fabric_stream`, otherwise the pattern is the same:
* Start a client monitor process with the set of initial workers to monitor
the coordinator and the client socket connection state.
* In case of replacements, update the monitor with the newly spawned
replacement workers.
* On cleanup, call the previous `fabric_stream:cleanup/1` function, and also stop
the monitor process.
[1] https://github.com/apache/couchdb/commit/d5701f437183c3742aab5812e298d5bb80cb0c15
---
src/dreyfus/src/dreyfus_fabric.erl | 1 +
src/dreyfus/src/dreyfus_fabric_group1.erl | 4 +++-
src/dreyfus/src/dreyfus_fabric_group2.erl | 4 +++-
src/dreyfus/src/dreyfus_fabric_search.erl | 4 +++-
src/fabric/src/fabric_streams.erl | 4 +++-
5 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/dreyfus/src/dreyfus_fabric.erl b/src/dreyfus/src/dreyfus_fabric.erl
index 5689c1d4e..6603d05b5 100644
--- a/src/dreyfus/src/dreyfus_fabric.erl
+++ b/src/dreyfus/src/dreyfus_fabric.erl
@@ -136,6 +136,7 @@ handle_replacement(
NewCounters = lists:foldl(
fun(Repl, CounterAcc) ->
NewCounter = start_replacement(StartFun, StartArgs, Repl),
+ fabric_streams:add_worker_to_cleaner(self(), NewCounter),
fabric_dict:store(NewCounter, nil, CounterAcc)
end,
OldCounters,
diff --git a/src/dreyfus/src/dreyfus_fabric_group1.erl b/src/dreyfus/src/dreyfus_fabric_group1.erl
index 1edfd653f..8f26ec4ef 100644
--- a/src/dreyfus/src/dreyfus_fabric_group1.erl
+++ b/src/dreyfus/src/dreyfus_fabric_group1.erl
@@ -56,6 +56,8 @@ go(DbName, DDoc, IndexName, #index_query_args{} = QueryArgs) ->
replacements = Replacements,
ring_opts = RingOpts
},
+ ClientReq = chttpd_util:mochiweb_client_req_get(),
+ fabric_streams:spawn_worker_cleaner(self(), Workers, ClientReq),
try
rexi_utils:recv(
Workers,
@@ -67,7 +69,7 @@ go(DbName, DDoc, IndexName, #index_query_args{} = QueryArgs) ->
)
after
rexi_monitor:stop(RexiMon),
- fabric_util:cleanup(Workers)
+ fabric_streams:cleanup(Workers)
end;
go(DbName, DDoc, IndexName, OldArgs) ->
go(DbName, DDoc, IndexName, dreyfus_util:upgrade(OldArgs)).
diff --git a/src/dreyfus/src/dreyfus_fabric_group2.erl b/src/dreyfus/src/dreyfus_fabric_group2.erl
index e962c7e4a..8385661a5 100644
--- a/src/dreyfus/src/dreyfus_fabric_group2.erl
+++ b/src/dreyfus/src/dreyfus_fabric_group2.erl
@@ -61,6 +61,8 @@ go(DbName, DDoc, IndexName, #index_query_args{} = QueryArgs) ->
replacements = Replacements,
ring_opts = RingOpts
},
+ ClientReq = chttpd_util:mochiweb_client_req_get(),
+ fabric_streams:spawn_worker_cleaner(self(), Workers, ClientReq),
try
rexi_utils:recv(
Workers,
@@ -72,7 +74,7 @@ go(DbName, DDoc, IndexName, #index_query_args{} = QueryArgs) ->
)
after
rexi_monitor:stop(RexiMon),
- fabric_util:cleanup(Workers)
+ fabric_streams:cleanup(Workers)
end;
go(DbName, DDoc, IndexName, OldArgs) ->
go(DbName, DDoc, IndexName, dreyfus_util:upgrade(OldArgs)).
diff --git a/src/dreyfus/src/dreyfus_fabric_search.erl b/src/dreyfus/src/dreyfus_fabric_search.erl
index bb104892b..e19d1cd7f 100644
--- a/src/dreyfus/src/dreyfus_fabric_search.erl
+++ b/src/dreyfus/src/dreyfus_fabric_search.erl
@@ -113,6 +113,8 @@ go(DbName, DDoc, IndexName, QueryArgs, Counters, Bookmark, RingOpts) ->
replacements = Replacements,
ring_opts = RingOpts
},
+ ClientReq = chttpd_util:mochiweb_client_req_get(),
+ fabric_streams:spawn_worker_cleaner(self(), Workers, ClientReq),
RexiMon = fabric_util:create_monitors(Workers),
try
rexi_utils:recv(
@@ -144,7 +146,7 @@ go(DbName, DDoc, IndexName, QueryArgs, Counters, Bookmark, RingOpts) ->
{error, Reason}
after
rexi_monitor:stop(RexiMon),
- fabric_util:cleanup(Workers)
+ fabric_streams:cleanup(Workers)
end.
handle_message({ok, #top_docs{} = NewTopDocs}, Shard, State0) ->
diff --git a/src/fabric/src/fabric_streams.erl b/src/fabric/src/fabric_streams.erl
index 20ee98fd2..b7c6b3afc 100644
--- a/src/fabric/src/fabric_streams.erl
+++ b/src/fabric/src/fabric_streams.erl
@@ -17,7 +17,9 @@
start/3,
start/4,
start/5,
- cleanup/1
+ cleanup/1,
+ spawn_worker_cleaner/3,
+ add_worker_to_cleaner/2
]).
-include_lib("fabric/include/fabric.hrl").