Skip to content

sql: implement crdb_internal.transaction_statistics#69049

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
Azhng:sqlstats-new-txnstats-view
Aug 23, 2021
Merged

sql: implement crdb_internal.transaction_statistics#69049
craig[bot] merged 2 commits intocockroachdb:masterfrom
Azhng:sqlstats-new-txnstats-view

Conversation

@Azhng
Copy link
Copy Markdown
Contributor

@Azhng Azhng commented Aug 17, 2021

Depends on #68715 and #69022

First Commit

roachpb,sql,server: add TransactionFingerprintID to
roachpb.CollectedTransactionStatistics

Previously, roachpb.CollectedTransactionStatistics does not contain
TransactionFingerprintID. This results in SQLStatusServer's
/_status/statements endpoint not able to return transaction
fingerprint id in the response.
This commit adds transaction fingerprint id into CollectedTransactionStatistics
and simplifies the API in multiple layers.

Release note: None

Second Commit

sql: introduce crdb_internal.transaction_statistics virtual table

This commit introduces crdb_internal.transaction_statistics virtual
table that exposes both cluster-wide in-memory transaction statistics
as well as persited transaction statistics. This new virtual table
will be used to replace crdb_internal.node_transaction_statistics
virtual table, which only surface node-local in-memory transaction
statsitics.

Follow up to #68715

Release justification: Category 4

Release note (sql change): introduced new crdb_internal.transaction_statistics
virtual table that surfaces both cluster-wide in-memory transaction statistics
as well as persisted transaction statistics.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@Azhng Azhng force-pushed the sqlstats-new-txnstats-view branch 3 times, most recently from 403eec8 to 22f30db Compare August 17, 2021 21:32
@Azhng Azhng requested a review from a team August 17, 2021 21:32
@Azhng Azhng marked this pull request as ready for review August 17, 2021 21:32
@Azhng Azhng requested review from a team as code owners August 17, 2021 21:32
@Azhng Azhng requested review from a team and removed request for a team August 17, 2021 21:32
@Azhng Azhng force-pushed the sqlstats-new-txnstats-view branch 2 times, most recently from d79e334 to 263c92b Compare August 18, 2021 03:43
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 15 of 15 files at r1, 14 of 14 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @Azhng)

Copy link
Copy Markdown
Contributor

@ajwerner ajwerner 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 15 of 15 files at r1, 5 of 14 files at r2, all commit messages.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @Azhng)


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

		if err != nil {
			return nil, nil, err
		}

thoughts on adding the memory in use for these stats to the monitor here and then releasing it in the worker? It's not perfect but it's better than nothing.


pkg/sql/sqlstats/sslocal/temp_sql_stats.go, line 51 at r2 (raw file):

// Less implements the sort.Interface interface.
func (t txnResponseList) Less(i, j int) bool {
	return strings.Compare(t[i].StatsData.App, t[j].StatsData.App) == -1

This is usually written as < 0 but also, why not t[i].StatsData.App < t[j].StatsData.App?

Azhng added 2 commits August 23, 2021 10:15
 roachpb.CollectedTransactionStatistics

Previously, roachpb.CollectedTransactionStatistics does not contain
TransactionFingerprintID. This results in SQLStatusServer's
/_status/statements endpoint not able to return transaction
fingerprint id in the response.
This commit adds transaction fingerprint id into CollectedTransactionStatistics
and simplifies the API in multiple layers.

Release note: None
This commit introduces crdb_internal.transaction_statistics virtual
table that exposes both cluster-wide in-memory transaction statistics
as well as persited transaction statistics. This new virtual table
will be used to replace crdb_internal.node_transaction_statistics
virtual table, which only surface node-local in-memory transaction
statsitics.

Follow up to cockroachdb#68715

Release note (sql change): introduced new crdb_internal.transaction_statistics
 virtual table that surfaces both cluster-wide in-memory transaction statistics
 as well as persisted transaction statistics.

Release justification: Category 4
@Azhng Azhng force-pushed the sqlstats-new-txnstats-view branch from 263c92b to 971bacd Compare August 23, 2021 14:59
Copy link
Copy Markdown
Contributor Author

@Azhng Azhng 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 2 stale) (waiting on @ajwerner and @maryliag)


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

Previously, ajwerner wrote…

thoughts on adding the memory in use for these stats to the monitor here and then releasing it in the worker? It's not perfect but it's better than nothing.

Done. I think it's ok for a stopgap solution for now. Left a TODO here that reference the tracking issue.


pkg/sql/sqlstats/sslocal/temp_sql_stats.go, line 51 at r2 (raw file):

Previously, ajwerner wrote…

This is usually written as < 0 but also, why not t[i].StatsData.App < t[j].StatsData.App?

Done. TIL < works on strings.

@Azhng
Copy link
Copy Markdown
Contributor Author

Azhng commented Aug 23, 2021

TFTR!

bors r=ajwerner,maryliag

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 23, 2021

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.

4 participants