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

ui: add statement fingerprint to insights #96872

Merged
merged 1 commit into from
Feb 13, 2023
Merged

ui: add statement fingerprint to insights #96872

merged 1 commit into from
Feb 13, 2023

Conversation

j82w
Copy link
Contributor

@j82w j82w commented Feb 9, 2023

  1. Removes contention events from insights. This avoids tracking and storing duplicate information.

  2. Add database_name, schema_name, table_name, index_name, contending_pretty_key to crdb_internal.transaction_contention_events. This avoids needing to join with multiple tables and makes it easier for users to understand.

  3. Add waiting statement info to the insights transaction details page. This way if users have a large transaction with multiple statements with multiple contention events they can see which specific statement was waited on.

  4. Add blocking transaction fingerprint to the insight statement details page. The user can now see which transaction is blocking the statement ,and it has a link to the blocking transaction activity page.

https://www.loom.com/share/de37b2e3007d48c2a1e3ad39ed334e20

closes: #91665

Release note (ui change): Add waiting statement id and fingerprint to insights transaction details page. Add blocking transaction id and fingerprint to the insights statement page.

@j82w j82w requested review from a team February 9, 2023 15:12
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link

@THardy98 THardy98 left a comment

Choose a reason for hiding this comment

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

Just watched the demo.

On the page listing the details of a transaction execution insight, would it be possible to link the Statement Waiting Execution ID to its corresponding statement execution insight page?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

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.

Reviewed 14 of 14 files at r1, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @j82w)


-- commits line 7 at r1:
what happens if a user renames one of these items?


pkg/sql/crdb_internal.go line 6459 at r1 (raw file):

    contention_duration          INTERVAL NOT NULL,
    contending_key               BYTES NOT NULL,
		contending_pretty_key     	 STRING NOT NULL,

nit: spacing


pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/insightDetailsTables.tsx line 61 at r1 (raw file):

        InsightExecEnum.STATEMENT,
      ),
      cell: (item: ContentionEvent) => item.waitingStmtFingerprintID,

can you make this be a link to the details page for the fingerprint?


pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/insightDetailsTables.tsx line 160 at r1 (raw file):

      name: "databaseName",
      title: insightsTableTitles.databaseName(execType),
      cell: (item: ContentionDetails) => item.databaseName,

should we also add link for the database/table/index page? If we do, you might have to save the ids instead of the names, in case people rename and you might get a database not found of even if another get renamed with the same name, users would get confused


pkg/sql/crdb_internal_test.go line 986 at r1 (raw file):

					 waiting_txn_fingerprint_id, 'hex'
			 ) AS waiting_txn_fingerprint_id,
      contending_pretty_key,

nit: spacing

@j82w
Copy link
Contributor Author

j82w commented Feb 9, 2023

To create a link for the statement fingerprint it is required to know if it is implicit or not. It should be possible to get the information, but figured it would be better to do it in a follow up PR since this is already a large PR.

@j82w
Copy link
Contributor Author

j82w commented Feb 9, 2023

-- commits line 7 at r1:

Previously, maryliag (Marylia Gutierrez) wrote…

what happens if a user renames one of these items?

It gets the name when the table is generated. It's possible if the user deletes a table or index that it will be empty string.

@j82w
Copy link
Contributor Author

j82w commented Feb 9, 2023

pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/insightDetailsTables.tsx line 160 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

should we also add link for the database/table/index page? If we do, you might have to save the ids instead of the names, in case people rename and you might get a database not found of even if another get renamed with the same name, users would get confused

When the virtual table is generated the contention key is parsed to the get the ids. It then gets the names based on the ids. It will always have the correct name even if it is renamed. The one issue is if users delete a table or index. If they deleted then there shouldn't be a reason to investigate a contention event.

@j82w
Copy link
Contributor Author

j82w commented Feb 9, 2023

I added the link in the latest iteration.

@j82w
Copy link
Contributor Author

j82w commented Feb 9, 2023

pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/insightDetailsTables.tsx line 61 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

can you make this be a link to the details page for the fingerprint?

I figured it would be better to do in a follow up PR. We don't have if the statement is implicit or not which is required to create the link.

@j82w
Copy link
Contributor Author

j82w commented Feb 9, 2023

pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/insightDetailsTables.tsx line 61 at r1 (raw file):

Previously, j82w (Jake) wrote…

I figured it would be better to do in a follow up PR. We don't have if the statement is implicit or not which is required to create the link.

Done

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.

Nice!
:lgtm:

Reviewed 8 of 8 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @j82w)


-- commits line 7 at r1:

Previously, j82w (Jake) wrote…

It gets the name when the table is generated. It's possible if the user deletes a table or index that it will be empty string.

Ah okay!


pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/insightDetailsTables.tsx line 61 at r1 (raw file):

Previously, j82w (Jake) wrote…

Done

Awesome!

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! Just some small nits and questions.

Copy link
Contributor Author

@j82w j82w 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 (and 1 stale) (waiting on @maryliag and @xinhaoz)


pkg/ui/workspaces/cluster-ui/src/api/stmtInsightsApi.ts line 180 at r4 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

Do we surface these executions?

It looks like they all get filtered out. I'll remove the check.


pkg/ui/workspaces/cluster-ui/src/api/txnInsightsApi.ts line 216 at r4 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

Can we extract this into its own file? I'm surprised there is no circular dependency between stmtInsightsApi and txnInsightsApi

Done.

1. Removes contention events from insights. This avoids
tracking and storing duplicate information.

2. Add database_name, schema_name, table_name, index_name,
contending_pretty_key to crdb_internal.transaction_contention_events.
This avoids needing to join with multiple tables and makes it easier for
users to understand.

3. Add waiting statement info to the insights transaction details page.
This way if users have a large transaction with multiple statements with
multiple contention events they can see which specific statement was
waited on.

4. Add blocking transaction fingerprint to the insight statement details
page. The user can now see which transaction is blocking the statement
,and it has a link to the blocking transaction activity page.

closes: #91665

Release note (ui change): Add waiting statement id and fingerprint to
insights transaction details page. Add blocking transaction id and
fingerprint to the insights statement page.
@j82w
Copy link
Contributor Author

j82w commented Feb 10, 2023

pkg/ui/workspaces/cluster-ui/src/api/contentionApi.ts line 45 at r5 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

nit: I don't believe we capitalize functions even if they're exported for TS. Only type names / classes / components.

Fixed

@j82w
Copy link
Contributor Author

j82w commented Feb 13, 2023

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 13, 2023

Build succeeded:

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.

insights: add blocking transaction fingerprint to statement details page
5 participants