You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2023/04/04 09:55:04 UTC
[couchdb] branch dreyfus-await-time updated (ae48f13d3 -> 126a28cda)
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a change to branch dreyfus-await-time
in repository https://gitbox.apache.org/repos/asf/couchdb.git
discard ae48f13d3 WIP send await time in response header - dreyfus
discard e03020789 Improve couch_proc_manager
new 126a28cda WIP send await time in response header - dreyfus
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 (ae48f13d3)
\
N -- N -- N refs/heads/dreyfus-await-time (126a28cda)
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:
rel/overlay/etc/default.ini | 7 -
src/chttpd/src/chttpd_show.erl | 5 +-
src/couch/include/couch_db.hrl | 9 +-
src/couch/src/couch_changes.erl | 2 +-
src/couch/src/couch_db.erl | 2 +-
src/couch/src/couch_db_updater.erl | 2 +-
src/couch/src/couch_doc.erl | 10 +-
src/couch/src/couch_native_process.erl | 2 +-
src/couch/src/couch_os_process.erl | 2 +-
src/couch/src/couch_proc_manager.erl | 660 +++++++----------
src/couch/src/couch_query_servers.erl | 106 +--
src/couch/test/eunit/couch_auth_cache_tests.erl | 3 +-
src/couch/test/eunit/couch_query_servers_tests.erl | 2 +-
src/couch/test/eunit/couchdb_os_proc_pool.erl | 796 +++++++--------------
src/couch_mrview/src/couch_mrview_show.erl | 5 +-
.../src/ddoc_cache_entry_validation_funs.erl | 2 +-
16 files changed, 546 insertions(+), 1069 deletions(-)
[couchdb] 01/01: WIP send await time in response header - dreyfus
Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch dreyfus-await-time
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 126a28cdacc765a36b40b7cf8338762254410ce5
Author: Robert Newson <rn...@apache.org>
AuthorDate: Tue Apr 4 10:32:52 2023 +0100
WIP send await time in response header - dreyfus
---
src/dreyfus/src/dreyfus_fabric_search.erl | 20 ++++++++++++++++----
src/dreyfus/src/dreyfus_httpd.erl | 24 ++++++++++++++++--------
src/dreyfus/src/dreyfus_rpc.erl | 3 +++
3 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/src/dreyfus/src/dreyfus_fabric_search.erl b/src/dreyfus/src/dreyfus_fabric_search.erl
index 7e78e5fc3..77a19d44a 100644
--- a/src/dreyfus/src/dreyfus_fabric_search.erl
+++ b/src/dreyfus/src/dreyfus_fabric_search.erl
@@ -27,7 +27,8 @@
counters,
start_args,
replacements,
- ring_opts
+ ring_opts,
+ await_time = 0
}).
go(DbName, GroupId, IndexName, QueryArgs) when is_binary(GroupId) ->
@@ -125,7 +126,7 @@ go(DbName, DDoc, IndexName, QueryArgs, Counters, Bookmark, RingOpts) ->
)
of
{ok, Result} ->
- #state{top_docs = TopDocs} = Result,
+ #state{top_docs = TopDocs, await_time = AwaitTime} = Result,
#top_docs{
total_hits = TotalHits,
hits = Hits,
@@ -134,11 +135,11 @@ go(DbName, DDoc, IndexName, QueryArgs, Counters, Bookmark, RingOpts) ->
} = TopDocs,
case RawBookmark of
true ->
- {ok, Bookmark, TotalHits, Hits, Counts, Ranges};
+ {ok, Bookmark, TotalHits, Hits, Counts, Ranges, AwaitTime};
false ->
Bookmark1 = dreyfus_bookmark:update(Sort, Bookmark, Hits),
Hits1 = remove_sortable(Hits),
- {ok, Bookmark1, TotalHits, Hits1, Counts, Ranges}
+ {ok, Bookmark1, TotalHits, Hits1, Counts, Ranges, AwaitTime}
end;
{error, Reason} ->
{error, Reason}
@@ -178,6 +179,17 @@ handle_message({ok, {top_docs, UpdateSeq, TotalHits, Hits}}, Shard, State) ->
hits = Hits
},
handle_message({ok, TopDocs}, Shard, State);
+handle_message({await_time, Time}, Shard, State) ->
+ case fabric_dict:lookup_element(Shard, State#state.counters) of
+ undefined ->
+ %% already heard from someone else in this range
+ {ok, State};
+ nil ->
+ State1 = State#state{
+ await_time = max(Time, State#state.await_time)
+ },
+ {ok, State1}
+ end;
handle_message(Error, Worker, State0) ->
State = upgrade_state(State0),
case
diff --git a/src/dreyfus/src/dreyfus_httpd.erl b/src/dreyfus/src/dreyfus_httpd.erl
index f6607d644..ae7826ce3 100644
--- a/src/dreyfus/src/dreyfus_httpd.erl
+++ b/src/dreyfus/src/dreyfus_httpd.erl
@@ -26,7 +26,7 @@
-include_lib("couch/include/couch_db.hrl").
-import(chttpd, [
send_method_not_allowed/2,
- send_json/2, send_json/3,
+ send_json/2, send_json/3, send_json/4,
send_error/2
]).
@@ -68,7 +68,7 @@ handle_search_req(
{rows, Hits}
]}
);
- {ok, Bookmark0, TotalHits, Hits0, Counts0, Ranges0} ->
+ {ok, Bookmark0, TotalHits, Hits0, Counts0, Ranges0, AwaitTime} ->
Hits = hits_to_json(DbName, IncludeDocs, Hits0),
Bookmark = dreyfus_bookmark:pack(Bookmark0),
Counts =
@@ -85,13 +85,21 @@ handle_search_req(
_ ->
[{ranges, facets_to_json(Ranges0)}]
end,
- send_json(Req, 200, {
+ AwaitTimeMs = erlang:convert_time_unit(AwaitTime, native, millisecond),
+ send_json(
+ Req,
+ 200,
[
- {total_rows, TotalHits},
- {bookmark, Bookmark},
- {rows, Hits}
- ] ++ Counts ++ Ranges
- });
+ {"x-cloudant-await-time", integer_to_list(AwaitTimeMs)}
+ ],
+ {
+ [
+ {total_rows, TotalHits},
+ {bookmark, Bookmark},
+ {rows, Hits}
+ ] ++ Counts ++ Ranges
+ }
+ );
{error, Reason} ->
handle_error(Req, Db, DDoc, RetryCount, RetryPause, Reason)
end;
diff --git a/src/dreyfus/src/dreyfus_rpc.erl b/src/dreyfus/src/dreyfus_rpc.erl
index 2ebc5ffe5..4c2e64a8b 100644
--- a/src/dreyfus/src/dreyfus_rpc.erl
+++ b/src/dreyfus/src/dreyfus_rpc.erl
@@ -48,9 +48,12 @@ call(Fun, DbName, DDoc, IndexName, QueryArgs0) ->
{ok, Index} ->
case dreyfus_index_manager:get_index(DbName, Index) of
{ok, Pid} ->
+ T0 = erlang:monotonic_time(),
case dreyfus_index:await(Pid, MinSeq) of
{ok, IndexPid, _Seq} ->
+ T1 = erlang:monotonic_time(),
Result = dreyfus_index:Fun(IndexPid, QueryArgs),
+ rexi:reply({await_time, T1 - T0}),
rexi:reply(Result);
% obsolete clauses, remove after upgrade
ok ->