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: update transaction insight details SQL query to not select from crdb_internal.ranges #94803

Conversation

ericharmeling
Copy link
Contributor

@ericharmeling ericharmeling commented Jan 5, 2023

Fixes #94445.

This commit updates the SQL-over-HTTP query executed on behalf of the transaction insight details page to not select from the crdb_internal.ranges table, and instead select from other internal tables.

Loom: https://www.loom.com/share/c5f0ffc201ef44778ef724c8f53538fc

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ericharmeling ericharmeling changed the title ui: update transaction insight details SQL query to no select from crdb_internal.ranges ui: update transaction insight details SQL query to not select from crdb_internal.ranges Jan 5, 2023
@ericharmeling ericharmeling requested a review from a team January 5, 2023 23:03
@ericharmeling ericharmeling force-pushed the transaction-insights-query-no-ranges branch from aaf62a0 to 25f0f4c Compare January 5, 2023 23:08
@ericharmeling ericharmeling marked this pull request as ready for review January 6, 2023 14:35
@ericharmeling ericharmeling requested a review from a team as a code owner January 6, 2023 14:35
@ericharmeling ericharmeling removed the request for review from a team January 6, 2023 19:56
@ericharmeling ericharmeling marked this pull request as draft January 6, 2023 20:30
@ericharmeling ericharmeling force-pushed the transaction-insights-query-no-ranges branch from 25f0f4c to 995ee7d Compare January 6, 2023 21:29
@ericharmeling ericharmeling marked this pull request as ready for review January 6, 2023 21:58
Copy link
Contributor

@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 (waiting on @ericharmeling)


pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 309 at r2 (raw file):

// txnContentionDetailsQuery selects information about a specific transaction contention event.
const txnContentionDetailsQuery = (id: string) => `

Why are we not just using the contention information from insights contention events?

contention_events JSONB,

Copy link
Contributor Author

@ericharmeling ericharmeling 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 @j82w)


pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 309 at r2 (raw file):

Previously, j82w (Jake) wrote…

Why are we not just using the contention information from insights contention events?

contention_events JSONB,

For a couple reasons:

  1. This change works on both 22.2 and 23.1 and, if backported, it unblocks https://github.com/cockroachlabs/managed-service/pull/10854 on 22.2. Selecting from the contention_events column wouldn't work on 22.2.

  2. IIUC, cluster_execution_insights captures statement executions whose execution time crosses a specific latency threshold. There could be a transaction with cumulative contention that surpasses the same threshold, but whose individual statements do not (and would therefore not be captured in cluster_execution_insights). But please correct me if I'm missing something.

Copy link
Contributor

@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 (waiting on @ericharmeling)


pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 309 at r2 (raw file):

Previously, ericharmeling (Eric Harmeling) wrote…

For a couple reasons:

  1. This change works on both 22.2 and 23.1 and, if backported, it unblocks https://github.com/cockroachlabs/managed-service/pull/10854 on 22.2. Selecting from the contention_events column wouldn't work on 22.2.

  2. IIUC, cluster_execution_insights captures statement executions whose execution time crosses a specific latency threshold. There could be a transaction with cumulative contention that surpasses the same threshold, but whose individual statements do not (and would therefore not be captured in cluster_execution_insights). But please correct me if I'm missing something.

  1. That makes sense, but I'm a little surprised we would backport it 22.2 instead of just waiting for 23.1.
  2. I thought the insights txn page was converted to pull all the information from cluster_execution_insights. That way it only shows query captured by the insights logic, and it's no longer a concern about the inconsistency in capture/retention policies. Since it from cluster_execution_insights it should already have all the contention events and not need to do an extra query.

pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 334 at r2 (raw file):

               table_id
        FROM
          "".crdb_internal.tables] AS tables ON tce.contending_key BETWEEN crdb_internal.table_span(tables.table_id)[1]

What happens if the table index was dropped or changed? Should it still return the result but leave the names as "no longer exists".

Copy link
Contributor

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

:lgtm:

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

@ericharmeling ericharmeling force-pushed the transaction-insights-query-no-ranges branch from 995ee7d to b1a01a7 Compare January 10, 2023 15:00
Copy link
Contributor Author

@ericharmeling ericharmeling 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 @j82w)


pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 309 at r2 (raw file):

I'm a little surprised we would backport it 22.2 instead of just waiting for 23.1.

@kevin-v-ngo IIUC, we do want insights on CC console for 22.2 serverless clusters, correct? If not, we might be able to simplify this query a bit using the newer 23.1 SHOW RANGES syntax. But I don't think we'll be able to join on cluster_execution_insights. contention_events for the reasons I mention below.

I thought the insights txn page was converted to pull all the information from cluster_execution_insights

The transaction insights page currently pulls from both cluster_execution_insights and transaction_contention_events.

The transactionInsights reducer uses the getTxnInsightEvents API function to pull from transaction_contention_events.

The executionInsights reducer uses getClusterInsightsApi to pull from cluster_execution_insights.

Then the selectTransactionInsights selector combines the transactionInsights and executionInsights slices. Entries with the same txn ID are merged, but if there are no duplicates (e.g., there is a contention event in transaction_contention_events but not in cluster_execution_insights), then the selector will just use the information in the slice with data to populate a row (e.g., a row with a txnID from transaction_contention_events that doesn't exist in cluster_execution_insights).

I think the end goal is to have all insights pages only pull from cluster_execution_insights, but that isn't what is happening right now.


pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 334 at r2 (raw file):

Previously, j82w (Jake) wrote…

What happens if the table index was dropped or changed? Should it still return the result but leave the names as "no longer exists".

Good question! I don't know of a sensical way to determine if an index existed and now doesn't. Before, there was no index for a given contention event, we just defaulted to the primary index. But this query actually does select and return the primary index. I just changed this to "index not found" to cover this case.

@ericharmeling ericharmeling added the backport-22.2.x Flags PRs that need to be backported to 22.2. label Jan 10, 2023
@j82w
Copy link
Contributor

j82w commented Jan 11, 2023

pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 309 at r2 (raw file):

Previously, ericharmeling (Eric Harmeling) wrote…

I'm a little surprised we would backport it 22.2 instead of just waiting for 23.1.

@kevin-v-ngo IIUC, we do want insights on CC console for 22.2 serverless clusters, correct? If not, we might be able to simplify this query a bit using the newer 23.1 SHOW RANGES syntax. But I don't think we'll be able to join on cluster_execution_insights. contention_events for the reasons I mention below.

I thought the insights txn page was converted to pull all the information from cluster_execution_insights

The transaction insights page currently pulls from both cluster_execution_insights and transaction_contention_events.

The transactionInsights reducer uses the getTxnInsightEvents API function to pull from transaction_contention_events.

The executionInsights reducer uses getClusterInsightsApi to pull from cluster_execution_insights.

Then the selectTransactionInsights selector combines the transactionInsights and executionInsights slices. Entries with the same txn ID are merged, but if there are no duplicates (e.g., there is a contention event in transaction_contention_events but not in cluster_execution_insights), then the selector will just use the information in the slice with data to populate a row (e.g., a row with a txnID from transaction_contention_events that doesn't exist in cluster_execution_insights).

I think the end goal is to have all insights pages only pull from cluster_execution_insights, but that isn't what is happening right now.

I'm actually changing my opinion to agree that it should just pull from the 'transaction_contention_events'. Duplicating the info in both insights and contention caches doesn't make sense. The 'transaction_contention_events' will very soon have all the waiting statement info too. LGTM

…rdb_internal.ranges

Fixes cockroachdb#94445.

This commit updates the SQL-over-HTTP query executed on behalf of the transaction
insight details page to not select from the crdb_internal.ranges table, and instead
select from other internal tables.

Release note: None
@ericharmeling ericharmeling force-pushed the transaction-insights-query-no-ranges branch from b1a01a7 to 40fcc96 Compare January 11, 2023 15:19
@ericharmeling
Copy link
Contributor Author

bors r+ single on

@rail
Copy link
Member

rail commented Jan 11, 2023

bors r-

@craig
Copy link
Contributor

craig bot commented Jan 11, 2023

Canceled.

@rail
Copy link
Member

rail commented Jan 11, 2023

bors r+ single off

@craig
Copy link
Contributor

craig bot commented Jan 11, 2023

This PR was included in a batch that successfully built, but then failed to merge into master. It will not be retried.

Additional information:

@ericharmeling ericharmeling merged commit d20dec1 into cockroachdb:master Jan 11, 2023
@blathers-crl
Copy link

blathers-crl bot commented Jan 11, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from 40fcc96 to blathers/backport-release-22.2-94803: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.2.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@rail
Copy link
Member

rail commented Jan 11, 2023

bors r-
We have temporarily disabled bors for merges. Please merge the PR manually when all required checks pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-22.2.x Flags PRs that need to be backported to 22.2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ui: update SQL API transaction contention query to not select from crdb_internal.ranges
4 participants