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

sql: add stmt error code to execution insights tables #96676

Closed
wants to merge 1 commit into from

Conversation

gtr
Copy link
Contributor

@gtr gtr commented Feb 6, 2023

Part of: #87785.

Previously, the insights subsystem did not keep track of error code for
failed executions and only contained a FailedExecution value for the
problem field. This commit adds the error_code column to the
crdb_internal.{cluster/node}_execution_insights virtual tables. This
commit also bubbles up that error code at the transaction level for
writing into the crdb_internal.{cluster/node}_txn_execution_insights
virtual table.

Release note (sql change): Adds error_code column to the
crdb_internal.{cluster/node}_execution_insights virtual tables, which
contains the error code for a failed execution. Adds last_error_code
column to the crdb_internal.{cluster/node}_txn_execution_insights
virtual tables, which is the error code of the last failed statement in
that transaction.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@gtr gtr marked this pull request as ready for review February 6, 2023 19:54
@gtr gtr requested review from a team February 6, 2023 19:54
@gtr gtr marked this pull request as draft February 6, 2023 21:06
@gtr gtr changed the title sql: add stmt error code and error message to crdb_internal execution insights table sql: add stmt error code to execution insights tables Feb 8, 2023
@gtr gtr marked this pull request as ready for review February 8, 2023 19:35
@gtr gtr removed request for a team February 8, 2023 19:43
@gtr gtr force-pushed the failed-stmt-insights branch 3 times, most recently from 0898d57 to 6770868 Compare February 9, 2023 16:12
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 update the file pkg/sql/sqlstats/insights/integration/insights_test.go to add the new column on the test TestInsightsIntegration and also create a new one testing the cases where you have errors (when the statement is slow so it would also hit that detector, but one that would still be fast and only hit the failed detector)

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


-- commits line 4 at r1:
these should be 2 different PRs, since they're not related
also, looks like the changes here are fixing 94381 and not just "part of"

Copy link
Contributor Author

@gtr gtr left a comment

Choose a reason for hiding this comment

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

Sure thing! I put the slow and failure detectors tests in pkg/sql/sqlstats/insights/detector_test.go.

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


-- commits line 4 at r1:

Previously, maryliag (Marylia Gutierrez) wrote…

these should be 2 different PRs, since they're not related
also, looks like the changes here are fixing 94381 and not just "part of"

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.

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


-- commits line 4 at r1:

Previously, gtr (Gerardo Torres Castro) wrote…

Done.

You tagged the wrong issue here.
This PR is dealing with 87785, and should be Part Of, since you haven't finish and still need to add to the UI.
The other PR which I imagine you're creating with the updates on the detector is the one where you tag as Fixes 94381

Part of: cockroachdb#87785.

Previously, the insights subsystem did not keep track of `error code` for
failed executions and only contained a `FailedExecution` value for the
problem field. This commit adds the `error_code` column to the
`crdb_internal.{cluster/node}_execution_insights` virtual tables. This
commit also bubbles up that error code at the transaction level for
writing into the `crdb_internal.{cluster/node}_txn_execution_insights`
virtual table.

Release note (sql change): Adds `error_code` column to the
`crdb_internal.{cluster/node}_execution_insights` virtual tables, which
contains the error code for a failed execution. Adds `last_error_code`
column to the `crdb_internal.{cluster/node}_txn_execution_insights`
virtual tables, which is the error code of the last failed statement in
that transaction.
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 @gtr)


pkg/sql/sqlstats/insights/integration/insights_test.go line 157 at r3 (raw file):

		var cpuSQLNanos int64
		var errorCode string
		err = row.Scan(&query, &startInsights, &endInsights, &implicitTxn, &cpuSQLNanos, &errorCode)

you need to add some test here with a failed execution and confirm that the error code is showing up as expected.
You should check in both statement and transaction insights

Copy link
Contributor Author

@gtr gtr 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)


-- commits line 4 at r1:

Previously, maryliag (Marylia Gutierrez) wrote…

You tagged the wrong issue here.
This PR is dealing with 87785, and should be Part Of, since you haven't finish and still need to add to the UI.
The other PR which I imagine you're creating with the updates on the detector is the one where you tag as Fixes 94381

Opened two PRs for the two issues:


pkg/sql/sqlstats/insights/integration/insights_test.go line 157 at r3 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

you need to add some test here with a failed execution and confirm that the error code is showing up as expected.
You should check in both statement and transaction insights

Done.

@gtr gtr closed this Feb 13, 2023
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.

3 participants