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

release-22.1: add new search criteria (limit, sort) to sql stats pages #103130

Merged
merged 10 commits into from May 22, 2023

Conversation

xinhaoz
Copy link
Member

@xinhaoz xinhaoz commented May 11, 2023

Backport 7/7 commits from #98815.

/cc @cockroachdb/release


See individual commits.

DB-Console: https://www.loom.com/share/86989713b95b4a728632e323c12088fe

Release justification: code yellow - high priority fixes

@blathers-crl
Copy link

blathers-crl bot commented May 11, 2023

Thanks for opening a backport.

Please check the backport criteria before merging:

  • Patches should only be created for serious issues or test-only changes.
  • Patches should not break backwards-compatibility.
  • Patches should change as little code as possible.
  • Patches should not change on-disk formats or node communication protocols.
  • Patches should not add new functionality.
  • Patches must not add, edit, or otherwise modify cluster versions; or add version gates.
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
  • There is a high priority need for the functionality that cannot wait until the next release and is difficult to address in another way.
  • The new functionality is additive-only and only runs for clusters which have specifically “opted in” to it (e.g. by a cluster setting).
  • New code is protected by a conditional check that is trivial to verify and ensures that it only runs for opt-in clusters.
  • The PM and TL on the team that owns the changed code have signed off that the change obeys the above rules.

Add a brief release justification to the body of your PR to justify this backport.

Some other things to consider:

  • What did we do to ensure that a user that doesn’t know & care about this backport, has no idea that it happened?
  • Will this work in a cluster of mixed patch versions? Did we test that?
  • If a user upgrades a patch version, uses this feature, and then downgrades, what happens?

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@xinhaoz xinhaoz force-pushed the backport22.1-98815 branch 3 times, most recently from acba7b8 to f64d806 Compare May 15, 2023 14:43
This commit adds a new field, fetch_mode, which
is a message containing an enum specifying what
kind of stats to return from the combined stmts
endpoint. The options are
- StmtStatsOnly
- TxnStatsOnly

Leaving this field null will fetch both stmts
and txns.

If `TxnStatsOnly` is specified, we will also include
the stmt stats for the stms in each txn in the returned
txn payload. This is because in the client app we need
the stmt stats to properly build the txn fingerprint pages.

In the future, we will split this API instead of using
this fetch mode flag, but this is currently preferred to
make it easier to backport for perf improvements.

Epic: none
Part of: cockroachdb#97252
Part of: cockroachdb#97875

Release note: None
Previously, both the stmt and txns fingerprints
pages were using the same api response from the
/statements. This was because we need the stmts
response to build txns pages. Howevever having to
fetch both types of stats can slow down the request.
Now that we can specify the fetch_mode as part of
the request, we can split the 2 into their own api
calls and redux fields.

Epic: none
Part of: cockroachdb#97875

Release note: None
This commit adds limit and sort fields to the combined
statements request. These params can be used to specify
how much data is returned and the priority at which to
return data (e.g. top-k). The current sort options are:
- service latency
- cpu time
- p99 (statements only)
- contention time
- execution count

Epic: none
Part of: cockroachdb#97876
Part of: cockroachdb#97875

Release note: None
@xinhaoz xinhaoz changed the title release-22.1: wip add new search criteria (limit, sort) to sql stats pages release-22.1: add new search criteria (limit, sort) to sql stats pages May 15, 2023
This commit changes the table used for the combined
stats endpoint from the view combining persisted and
in-memory stats to the view that is just a wrapper
around the system table. Thus, we are now reading
only persisted stats from the system table for the
combined stats endpoint.

This commit updates tests using the combined api to
flush stats before using the api.

Epic: None
Release note (ui change): On the SQL Activity fingerprints
pages, users will not see stats that have not yet been
flushed to disk.
@xinhaoz xinhaoz marked this pull request as ready for review May 16, 2023 16:10
@xinhaoz xinhaoz requested review from a team as code owners May 16, 2023 16:10
Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @xinhaoz)


pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx line 364 at r10 (raw file):

    const { pagination } = this.state;
    this.setState({ pagination: { ...pagination, current } });
    this.props.onPageChanged != null && this.props.onPageChanged(current);

we actually need this check, because this function could be empty (is just used for analytics), and I just had to create a PR to add this back onhttps://github.com//pull/103484/files#diff-b7e775c116135547929b4e0aa104a33aa09a26137d076187cbbc7e1504f1acb0R411-R413
(I'll be backporting that fix for 23.1 and 22.2, but since you haven't merge this yet make sense to already do the right thing here)

xinhaoz and others added 6 commits May 17, 2023 10:27
This commit adds new knobs to the sql stats
fingerprint pages. Users can now specify a
limit and sort priority with their sql stats
fingerprints requests.

Closes: cockroachdb#97876
Part of: cockroachdb#97875

Release note: None
Previously, the calculatation for the `% of runtime` column
for the sql activity pages, was performed on the client app
by summing the (execCount* avgAvcLat) from all statements
returned. This was okay when we were returning a large number
of stmts (20,000) but now that we have reduced that limit
significantly (default 100, with a max provided option of 500),
performing this calculation on the client side won't give us
the full picture of total runtime of the workload in the requested
time interval.

This commit modifies the statements API to return the total
estimated runtime of the workload so that we can continue to
show the '% of runtime` column. We also now provide this as a
server sort option, so that users can request the top-k stmts or
txns by % of runtime.

Epic: none

Release note (ui change): Users can request top-k stmts by
% runtime in sql activity fingerprints pages.
Create new Search Criteria component, and add
to Statements and Transactions page.
This commit also updates the UI, with the new
position of filters and reset sql stats.

Part Of cockroachdb#98891

Release note (ui change): Add Search Criteria to Statements and
Transactions pages, updates UX with improvements.
When we are on a new cluster-ui version that sends user configured
limit and sort values in the sql stats request, we may be talking
to an older server version that does not support those request
params. In that scenario, The server response will be that of the
request without limit and sort. This commit checks the response from
the server so that if we find that the payload limit is not equal
to the requested limit, we manually sort and truncate the response
to match the parameters the user sees on the UI.

Epic: none

Release note: None
This change adds some missing props to the txnDetailsPage story
file.

Epic: none

Release note: None
Previously the db tables page was using formatDate
from the antd project, which was causing test failures.
This commit swaps the usage to use moment's format
function directly.

Epic: none

Release note: None
Copy link
Member Author

@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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @maryliag)


pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx line 364 at r10 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

we actually need this check, because this function could be empty (is just used for analytics), and I just had to create a PR to add this back onhttps://github.com//pull/103484/files#diff-b7e775c116135547929b4e0aa104a33aa09a26137d076187cbbc7e1504f1acb0R411-R413
(I'll be backporting that fix for 23.1 and 22.2, but since you haven't merge this yet make sense to already do the right thing here)

Done.

@xinhaoz xinhaoz requested a review from a team May 18, 2023 14:51
Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

can you just add a loom confirming everything is working on 22.1 since the current loom was for the main branch?
otheriwse :lgtm:

Reviewed 3 of 3 files at r1, 21 of 21 files at r2, 2 of 2 files at r3, 4 of 4 files at r4, 12 of 20 files at r5, 34 of 34 files at r11, 12 of 12 files at r12, 20 of 20 files at r13, 4 of 4 files at r14, 2 of 2 files at r15, 1 of 1 files at r16, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @xinhaoz)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants