-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dbname to mango exec stats #4990
Conversation
d6d202a
to
0422558
Compare
to_json(Stats, true). | ||
|
||
to_json(Stats, IncludeDbName) -> | ||
Base = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you could just simply say:
Base = [{dbname, Stats#execution_stats.dbname} || IncludeDbName]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite following your suggestion, we need to include the tuple {dbname, Stats#execution_stats.dbname}
in the list conditionally. I think perhaps you're suggesting to move the construction of the the base into the arity one function head, like:
to_json(Stats) ->
to_json(Stats, [{dbname, Stats#execution_stats.dbname}]).
to_json(Stats, Base) ->
{[
...
| Base
]}.
But that would change the caller here https://github.com/apache/couchdb/pull/4990/files/69f80aa3a270030601ebd111bd3a1dc62a5df8fa#diff-478704bf59b4beb680fc69863dfe63a544cfea5d6dca7507d6ce080c84b6cb35R119 to have to supply the base list into to_json
, eg to_json(Stats, [])
instead of to_json(Stats, false)
, and I don't think having to supply the base list instead of a boolean is a cleaner approach.
Is this what you were suggesting or something else? I agree that it's a bit clunky for sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to change the function's interface. What I suggested is a semantical equivalent of your original definition. This alternative syntax is based on how list comprehensions in Erlang work. The Boolean value on the right-hand side of the ||
symbol acts as a predicate and the value on the left-hand side is added to the resulting list if that is true
otherwise omitted.
For example, consider the following in the Erlang shell:
> [1 || true].
[1]
> [1 || false].
[]
List comprehensions do not require the use of variables, hence this formulation becomes a valid although unusual instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhhh I see what you mean, I haven't seen that structure before. Interesting, but seems a bit esoteric. Perhaps if we make that a common pattern in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When applied in a sequence, it works out quite nicely:
couchdb/src/mango/src/mango_idx_view.erl
Lines 137 to 140 in 16bf9df
Reason = | |
[needs_text_search || not NotTextSearch] ++ | |
[field_mismatch || not SelectorHasRequiredFields] ++ | |
[sort_order_mismatch || not CanUseSort], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, it would look nice in this case as well. Of course, this is just a suggestion, I am adding this example for consideration only where Base
is removed completely:
{[
{total_keys_examined, Stats#execution_stats.totalKeysExamined},
{total_docs_examined, Stats#execution_stats.totalDocsExamined},
{total_quorum_docs_examined, Stats#execution_stats.totalQuorumDocsExamined},
{results_returned, Stats#execution_stats.resultsReturned},
{execution_time_ms, Stats#execution_stats.executionTimeMs}
| [{dbname, Stats#execution_stats.dbname} || IncludeDbName]
]}.
@@ -128,6 +129,8 @@ execute(Cursor, UserFun, UserAcc) -> | |||
{FinalUserAcc0, Stats1} = mango_execution_stats:maybe_add_stats( | |||
Opts, UserFun, Stats0, FinalUserAcc | |||
), | |||
%% This needs Stats1 as log_end is called in maybe_add_stats | |||
mango_execution_stats:log_stats(Stats1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
517fce8
to
22781e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 if passes the CI
The Mango integration test suites ( [2024-03-05T14:04:18.471Z] Ran 384 tests in 12.251s
[2024-03-05T14:04:18.471Z]
[2024-03-05T14:04:18.471Z] FAILED (failures=3, errors=75, skipped=143) |
This seems to be the cause:
|
aea49de
to
7928150
Compare
Okay, cool. Looks like all the issues have been fixed. |
* WIP: include dbname in mango exec stats * Don't output dbname in exec stats http response * Make sure mango nouveau logs reports * Test that mango reports get the dbname in the stats * With compliant formatting * Switch to adding exec stats dbname during create * Add stats to explain cursor * Add stats to mango cursor special * Fix mango special cursor test
Overview
This PR includes the database name in the
"mango-stats"
alongside the existing data around documents processed to generate the request. The motivation here is two fold: 1) there's a scenario wherechttpd:maybe_log
returns false and the chttpd socket handling the request has died where a front load balancer processing the request never got theX-Couch-Request-ID
, thereby losing the connection of the underlying request that induced the particular load; this is especially problematic when the socket died because the request was excessively long. 2) this allows for grouping by dbname directly on the reports, making it easier to quickly scan and summarize activity from the report.This PR also sneaks in a patch to
mango_cursor_nouveau
to include the recent stats logic patch.Testing recommendations
I've added a new test to show the
dbname
field arrives in thecouch_log:report
logic yet does not extend the field into the http response when the_find
query doesexecution_stats=true
.Checklist
rel/overlay/etc/default.ini
src/docs
folder