-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
server, ui: add sort and limit to sql activity pages, switch sql activity pages to read only from system table #98815
Conversation
bba0656
to
71b577a
Compare
71b577a
to
fac5400
Compare
fac5400
to
c9aa01a
Compare
c9aa01a
to
5349a9d
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.
nit: You should update your PR title, since it has a lot more than that
Can you add looms showing the new behaviour working on all SQL Activity pages on both DB and CC?
Reviewed 3 of 3 files at r1, 21 of 21 files at r2, 3 of 3 files at r3, 5 of 5 files at r4, 18 of 18 files at r5, 12 of 12 files at r6, 24 of 24 files at r7, 34 of 34 files at r8.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @xinhaoz)
-- commits
line 79 at r4:
you should add a release note here, because documentation will need to be updated to show users they might not see data that was just executed
pkg/server/combined_statement_stats.go
line 80 at r1 (raw file):
var err error if req.FetchMode == nil || req.FetchMode.StatsType != serverpb.CombinedStatementsStatsRequest_StmtStatsOnly {
nit: can you use StatsType == TxnStatsOnly to make more clear? Is a little confusing this way
pkg/server/combined_statement_stats.go
line 256 at r3 (raw file):
aostClause := testingKnobs.GetAOSTClause() query := fmt.Sprintf(` SELECT * FROM (
why you need this "wrapper" select?
pkg/server/combined_statement_stats.go
line 264 at r4 (raw file):
metadata, crdb_internal.merge_statement_stats(array_agg(statistics)) AS statistics FROM crdb_internal.statement_statistics_persisted %s
there are other places on this file that should also be updated to the new tables, e.g. all the calls on the details. Basically all usages should be replaced with the new views, since there is also performance issues on details endpoints
pkg/ui/workspaces/cluster-ui/src/api/statementsApi.ts
line 54 at r5 (raw file):
}; // THhe required fields to create a stmts request.
nit: The
pkg/ui/workspaces/cluster-ui/src/searchCriteria/searchCriteria.tsx
line 1 at r7 (raw file):
// Copyright 2021 The Cockroach Authors.
nit: 2023
pkg/ui/workspaces/cluster-ui/src/store/transactionStats/index.ts
line 1 at r2 (raw file):
// Copyright 2021 The Cockroach Authors.
nit: 2023
pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.reducer.ts
line 1 at r2 (raw file):
// Copyright 2021 The Cockroach Authors.
nit: 2023
pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.reducer.ts
line 41 at r2 (raw file):
}; // This is actually statements only, despite the SQLStatsState name.
this comment is not valid here
pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.reducer.ts
line 47 at r2 (raw file):
initialState, reducers: { received: (state, action: PayloadAction<StatementsResponse>) => {
maybe you want to add a comment that is indeed StatementResponse for Transaction, might be confusing for someone looking into this in the future and asking why they don't match
pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.sagas.ts
line 1 at r2 (raw file):
// Copyright 2021 The Cockroach Authors.
nit: 2023
pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.selector.ts
line 1 at r2 (raw file):
// Copyright 2021 The Cockroach Authors.
nit: 2023
pkg/ui/workspaces/db-console/src/util/api.ts
line 748 at r5 (raw file):
// getCombinedStatements returns statements the cluster has recently executed, and some stats about them. export function getCombinedStatements(
curious of why this is no longer needed
pkg/ui/workspaces/db-console/src/views/transactions/transactionDetails.tsx
line 39 at r5 (raw file):
import { selectTxnInsightsByFingerprint } from "src/views/insights/insightsSelectors"; import { selectHasAdminRole } from "src/redux/user"; import { limitSetting } from "./transactionsPage";
can you combine this with the import above with the other stuff coming from this file?
pkg/ccl/serverccl/statusccl/tenant_status_test.go
line 440 at r4 (raw file):
} for _, tenantStmt := range tenantCombinedStats.Statements {
why those tests were removed?
pkg/ccl/serverccl/statusccl/tenant_status_test.go
line 447 at r4 (raw file):
// ensure tests are deterministic. testCluster.TenantConn(0 /* idx */). Exec(t, "SET CLUSTER SETTING sql.stats.flush.interval = '24h'")
why can you just shut off the flush like it was done previously?
pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.sagas.spec.ts
line 1 at r2 (raw file):
// Copyright 2021 The Cockroach Authors.
nit: 2023
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
5349a9d
to
3a11825
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @maryliag)
pkg/server/combined_statement_stats.go
line 80 at r1 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
nit: can you use StatsType == TxnStatsOnly to make more clear? Is a little confusing this way
Done.
pkg/server/combined_statement_stats.go
line 256 at r3 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
why you need this "wrapper" select?
It's so that we can use the statistics column in the sort. Since merge_statement_statistics
isn't recognized as an aggregate function, we can't use it in the ORDER BY
.
pkg/server/combined_statement_stats.go
line 264 at r4 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
there are other places on this file that should also be updated to the new tables, e.g. all the calls on the details. Basically all usages should be replaced with the new views, since there is also performance issues on details endpoints
Done.
pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.reducer.ts
line 41 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
this comment is not valid here
Removed.
pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.reducer.ts
line 47 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
maybe you want to add a comment that is indeed StatementResponse for Transaction, might be confusing for someone looking into this in the future and asking why they don't match
Done.
pkg/ui/workspaces/db-console/src/util/api.ts
line 748 at r5 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
curious of why this is no longer needed
We can use the one exported from cluster-ui -- no need to duplicate it here.
pkg/ccl/serverccl/statusccl/tenant_status_test.go
line 440 at r4 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
why those tests were removed?
We're just reading from a system table now instead of in-memory. I thought we got segregated tables for tenants for free so this test isn't necessary anymore IIUC.
pkg/ccl/serverccl/statusccl/tenant_status_test.go
line 447 at r4 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
why can you just shut off the flush like it was done previously?
Well I checked the code and it in the code for Flush, if this is disabled, we do not flush. So this test actually was just testing in-memory both times before.
3a11825
to
dfe5ba2
Compare
af63465
to
543ce20
Compare
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
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.
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.
543ce20
to
ae9c259
Compare
bors r=maryliag |
1 similar comment
bors r=maryliag |
Already running a review |
Build failed (retrying...): |
Build succeeded: |
The fix done on cockroachdb#98177 was reverted on cockroachdb#98815, so this commit is adding the check back, which is necessary to not cause an undefined error. The value for AdminUI could take some time to be initialized, making calls using localStorage fail. This commit adds a check and return an empty object instead of undefined for localStorage. Epic: None Release note (bug fix): Fixes calls to undefined objects.
103484: ui: fix errors from undefined usage r=maryliag a=maryliag The fix done on #98177 was reverted on #98815, so this commit is adding the check back, which is necessary to not cause an undefined error. Example of error saw on Datadog: <img width="998" alt="Screenshot 2023-05-16 at 6 36 07 PM" src="https://github.com/cockroachdb/cockroach/assets/1017486/0e979df8-e66e-4b3c-9cb6-24ace5dd26fd"> The value for AdminUI could take some time to be initialized, making calls using localStorage fail. This commit adds a check and return an empty object instead of undefined for localStorage. Examples of this error saw on Datadog: <img width="1092" alt="Screenshot 2023-05-16 at 3 59 27 PM" src="https://github.com/cockroachdb/cockroach/assets/1017486/2553fdfc-54f5-4ec1-addf-1af597180e7a"> <img width="1180" alt="Screenshot 2023-05-16 at 4 00 59 PM" src="https://github.com/cockroachdb/cockroach/assets/1017486/f93e7c12-5fdd-490a-b072-298b7b2158ae"> Epic: None Release note (bug fix): Fixes calls to undefined objects. 103514: sql: fix recently introduced bug around the internal rowsIterator r=yuzefovich a=yuzefovich This commit fixes a minor bug introduced in c7eb1bf that could lead to a nil pointer panic. In particular, that commit introduced `HasResults` method to the `rowsIterator`, and it assumed that `first` field is always non-nil when the iterator was returned on `QueryIteratorEx` call. However, that is not true - in case an error was returned from the connExecutor goroutine, then `rowsIterator.lastErr` is set while `first` is left nil. The expectation is that in such a case the user of the iterator will receive that error either on `Next` or `Close` call, properly cleaning up the iterator. We might want to rethink this and return the error explicitly, but in the spirit of making the least amount of changes, this commit simply added the non-nil check for the `first` field. Fixes: #103508. Release note (bug fix): CockroachDB could previously encounter a nil pointer crash when populating data for SQL Activity page in some rare cases, and this is now fixed. The bug is present in 22.2.9 and 23.1.1 releases. Co-authored-by: maryliag <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]>
The fix done on #98177 was reverted on #98815, so this commit is adding the check back, which is necessary to not cause an undefined error. The value for AdminUI could take some time to be initialized, making calls using localStorage fail. This commit adds a check and return an empty object instead of undefined for localStorage. Epic: None Release note (bug fix): Fixes calls to undefined objects.
The fix done on cockroachdb#98177 was reverted on cockroachdb#98815, so this commit is adding the check back, which is necessary to not cause an undefined error. The value for AdminUI could take some time to be initialized, making calls using localStorage fail. This commit adds a check and return an empty object instead of undefined for localStorage. Epic: None Release note (bug fix): Fixes calls to undefined objects.
The fix done on cockroachdb#98177 was reverted on cockroachdb#98815, so this commit is adding the check back, which is necessary to not cause an undefined error. The value for AdminUI could take some time to be initialized, making calls using localStorage fail. This commit adds a check and return an empty object instead of undefined for localStorage. Epic: None Release note (bug fix): Fixes calls to undefined objects.
See individual commits.
DB-Console: https://www.loom.com/share/73248244baa54cdf80389d0eec788447
DB-Console Details pages: https://www.loom.com/share/2d74c6cf082f4dcfb5e7f690166c2baf