Skip to content
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

sqlstats: generate PCT_RUNTIME sort when requested #123846

Merged

Conversation

dhartunian
Copy link
Collaborator

Previously, when a request was made to the combined stats endpoint on CRDB with a PCT_RUNTIME sort, we'd default to a svcLatency sort instead because of a missing switch case.

This change fills that gap and adds some datadriven tests to inspect the resulting WHERE clauses.

Fixes: #123841
Epic: CRDB-37544

Release note (ui change): Viewing SQL Activity sorted by % of Runtime now correctly sorts entries by the runtime amount.

@dhartunian dhartunian requested a review from xinhaoz May 8, 2024 20:17
@dhartunian dhartunian requested a review from a team as a code owner May 8, 2024 20:17
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@dhartunian dhartunian added backport-23.1.x Flags PRs that need to be backported to 23.1 backport-23.2.x Flags PRs that need to be backported to 23.2. backport-24.1.x Flags PRs that need to be backported to 24.1. labels May 8, 2024
Copy link
Member

@xinhaoz xinhaoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice tests. I think in the future (as part of the redesign for this api) it'd be cool to do something like this where we can programmatically do this for all of the available sort options in the request.

Just the one comment with the sort and internal options.

&serverpb.CombinedStatementsStatsRequest{
FetchMode: &serverpb.CombinedStatementsStatsRequest_FetchMode{
StatsType: serverpb.CombinedStatementsStatsRequest_StmtStatsOnly,
Sort: serverpb.StatsSortOptions(serverpb.StatsSortOptions_value[sortString]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're missing the limit here, and I don't think internal is a field on the request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed that internal was being passed below in the function - ignore that part.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just took out internal as a flag in the test cases, and added start/end

@dhartunian dhartunian force-pushed the fix-missing-sort-for-pct-runtime branch 2 times, most recently from e563642 to 314bcf8 Compare May 8, 2024 20:51
--ARGS--
[1970-01-01 00:00:01 +0000 UTC 1970-01-01 00:00:02 +0000 UTC 100]

query sort=SERVICE_LAT limit=100 start=1 end=2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could we have some test cases where limit is something other than 100 / when it's omitted? Just to verify it's putting the correct value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Previously, when a request was made to the combined stats endpoint on
CRDB with a `PCT_RUNTIME` sort, we'd default to a `svcLatency` sort
instead because of a missing switch case.

This change fills that gap and adds some datadriven tests to inspect
the resulting `WHERE` clauses.

Fixes: cockroachdb#123841
Epic: CRDB-37544

Release note (ui change): Viewing SQL Activity sorted by `% of
Runtime` now correctly sorts entries by the runtime amount.
@dhartunian dhartunian force-pushed the fix-missing-sort-for-pct-runtime branch from 314bcf8 to a8636af Compare May 9, 2024 14:02
@dhartunian
Copy link
Collaborator Author

bors r=xinhaoz

@craig craig bot merged commit bf7788e into cockroachdb:master May 9, 2024
22 checks passed
@dhartunian dhartunian deleted the fix-missing-sort-for-pct-runtime branch May 9, 2024 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1 backport-23.2.x Flags PRs that need to be backported to 23.2. backport-24.1.x Flags PRs that need to be backported to 24.1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sqlstats: requests for % of all Runtime in SQL Activity are incorrectly sorted by svcLatency
3 participants