Skip to content

insights: record more txn insights#93079

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
xinhaoz:more-txn-fields
Dec 7, 2022
Merged

insights: record more txn insights#93079
craig[bot] merged 1 commit intocockroachdb:masterfrom
xinhaoz:more-txn-fields

Conversation

@xinhaoz
Copy link
Copy Markdown
Contributor

@xinhaoz xinhaoz commented Dec 5, 2022

Closes #93076

This commit adds the following fields at the txn level when recording
insights in the sql insights system:

  • contention: total txn contention time
  • start_time: txn start time
  • end_time: txn end time
  • auto_retry_reason: last reason for auto txn retry
  • retry_count
  • rows_written
  • rows_read

In addition, the following fields have been moved from recording at
the stmt level to recording at the txn level for insights:

  • user
  • application_name

Release note: None

@xinhaoz xinhaoz requested review from a team December 5, 2022 21:05
@xinhaoz xinhaoz requested a review from a team as a code owner December 5, 2022 21:05
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@xinhaoz xinhaoz removed request for a team December 5, 2022 21:05
Copy link
Copy Markdown
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 6 of 6 files at r1, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @xinhaoz)


pkg/sql/executor_statement_metrics.go line 211 at r1 (raw file):

		EndTime:              phaseTimes.GetSessionPhaseTime(sessionphase.PlannerStartExecStmt).Add(svcLatRaw),
		FullScan:             fullScan,
		SessionData:          planner.SessionData(),

I don't see the commit mentions the removal of the sessions data, is this what you mean by user/app/database?

@xinhaoz
Copy link
Copy Markdown
Contributor Author

xinhaoz commented Dec 6, 2022

pkg/sql/executor_statement_metrics.go line 211 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

I don't see the commit mentions the removal of the sessions data, is this what you mean by user/app/database?

Yes that's correct, that info was coming from the presence of the session data in the statements record.

Copy link
Copy Markdown

@matthewtodd matthewtodd 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 and @xinhaoz)


pkg/sql/crdb_internal.go line 6697 at r2 (raw file):

			tree.NewDString(insight.Transaction.User),
			tree.NewDString(insight.Transaction.ApplicationName),
			tree.NewDString(insight.Transaction.Database),

Great! Do you want to add the new values to the table, too, or is that for another commit?

@xinhaoz
Copy link
Copy Markdown
Contributor Author

xinhaoz commented Dec 6, 2022

pkg/sql/crdb_internal.go line 6697 at r2 (raw file):

Previously, matthewtodd (Matthew Todd) wrote…

Great! Do you want to add the new values to the table, too, or is that for another commit?

I'm going to split the table in the next PR. This is just to ensure the behaviour of the current exec insights doesn't change in this PR (and it seems fine to keep these fields in the stmt table version in addition to adding them to the incoming txns table, LMK if you think differently).

Copy link
Copy Markdown
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.

:lgtm:

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

Copy link
Copy Markdown
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! 1 of 0 LGTMs obtained (waiting on @maryliag, @matthewtodd, and @xinhaoz)


pkg/sql/crdb_internal.go line 6697 at r2 (raw file):

			tree.NewDString(insight.Transaction.User),
			tree.NewDString(insight.Transaction.ApplicationName),
			tree.NewDString(insight.Transaction.Database),

Is it possible for a single transaction to span multiple dbs?

@xinhaoz
Copy link
Copy Markdown
Contributor Author

xinhaoz commented Dec 6, 2022

pkg/sql/crdb_internal.go line 6697 at r2 (raw file):

Previously, j82w wrote…

Is it possible for a single transaction to span multiple dbs?

Hm I believe so, so this is probably more of a stmt-level stat. I'll move it back

Copy link
Copy Markdown

@matthewtodd matthewtodd 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! 2 of 0 LGTMs obtained (waiting on @j82w and @maryliag)

@xinhaoz xinhaoz force-pushed the more-txn-fields branch 2 times, most recently from 072bf51 to ebd73c0 Compare December 6, 2022 23:17
Closes cockroachdb#93076

This commit adds the following fields at the txn level when recording
insights in the sql insights system:
- contention: total txn contention time
- start_time: txn start time
- end_time: txn end time
- auto_retry_reason: last reason for auto txn retry
- retry_count
- rows_written
- rows_read

In addition, the following fields have been moved from recording at
the stmt level to recording at the txn level for insights:
- user
- application_name

Release note: None
@xinhaoz
Copy link
Copy Markdown
Contributor Author

xinhaoz commented Dec 7, 2022

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Dec 7, 2022

Build succeeded:

@craig craig bot merged commit 8248dce into cockroachdb:master Dec 7, 2022
@xinhaoz xinhaoz deleted the more-txn-fields branch February 9, 2023 21:01
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: record missing txn insights

5 participants