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 waiting stmt info to transaction_contention_events #95061

Merged
merged 1 commit into from
Feb 1, 2023
Merged

sql: add waiting stmt info to transaction_contention_events #95061

merged 1 commit into from
Feb 1, 2023

Conversation

j82w
Copy link
Contributor

@j82w j82w commented Jan 11, 2023

This adds the 'waiting_stmt_id' and 'waiting_stmt_fingerprint_id' to the transaction_contention_events. This makes it easier for users to figure out what the issue is when dealing with large transactions.

part of: #91665

Release note: sql: adds the 'waiting_stmt_id' and
'waiting_stmt_fingerprint_id' to the transaction_contention_events

@j82w j82w requested review from a team January 11, 2023 14:36
@j82w j82w requested a review from a team as a code owner January 11, 2023 14:36
@j82w j82w requested a review from msirek January 11, 2023 14:36
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

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

Reviewed 5 of 6 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @j82w and @msirek)


pkg/sql/contentionpb/contention.go line 95 at r2 (raw file):

// since uint64 is 8-byte. This is why we decode the byte array twice and add
// the resulting uint64 into the fnv each time.
func hashClusterUniqueID(id clusterunique.ID, hash *util.FNV64) {

You might want to update the comment for this function. It looks like it was copied over from hashUUID().

Copy link
Member

@yuzefovich yuzefovich 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 and @msirek)


-- commits line 11 at r3:
nit: the format should be Release note (sql change): adds .... IIUC the format matters because we have an automated script that docs writers use to populate the release notes that we send out, and if a release note in the commit message doesn't match the expected format, then the docs writer will need to do more manual stuff.


pkg/sql/crdb_internal.go line 6348 at r3 (raw file):

    contention_duration          INTERVAL NOT NULL,
    contending_key               BYTES NOT NULL,
    

nit: looks like dangling spaces.

Copy link
Contributor

@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 @j82w and @msirek)


pkg/sql/contentionpb/contention_test.go line 19 at r3 (raw file):

	"github.com/cockroachdb/cockroach/pkg/util/uuid"
	"github.com/stretchr/testify/require"
	"testing"

nit: Re-order "testing" import to the top of import list.

Copy link
Contributor

@msirek msirek left a comment

Choose a reason for hiding this comment

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

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


pkg/sql/contentionpb/contention.go line 93 at r4 (raw file):

// hashClusterUniqueID adds the hash of the clusterunique.ID into the fnv.
// A clusterunique.ID is an uint128. To hash we treat it as two uint64 integers,
// since uint128 is has a lo and hi uint64.

"since uint128 is has" -> "since uint128 has"

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.

:lgtm:

Reviewed 2 of 6 files at r1, 3 of 4 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @j82w)

@j82w j82w requested a review from a team January 19, 2023 12:43
@j82w j82w requested a review from a team as a code owner January 19, 2023 12:43
@j82w j82w requested a review from a team as a code owner January 19, 2023 13:19
Copy link
Contributor

@andreimatei andreimatei 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 @gtr, @j82w, @maryliag, @msirek, and @yuzefovich)


-- commits line 11 at r3:

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: the format should be Release note (sql change): adds .... IIUC the format matters because we have an automated script that docs writers use to populate the release notes that we send out, and if a release note in the commit message doesn't match the expected format, then the docs writer will need to do more manual stuff.

Also, if you are to have a release note, please make it a fuller sentence that a user can understand and make use of.
I would not add a note.


-- commits line 4 at r6:
what's the difference between a statement ID and a fingerprint ID ?


pkg/sql/clusterunique/id.go line 96 at r6 (raw file):

		return err
	}
	id.Hi = uint128.Hi

*id.Uint128 = uint128 ?

@j82w
Copy link
Contributor Author

j82w commented Jan 20, 2023

-- commits line 4 at r6:

Previously, andreimatei (Andrei Matei) wrote…

what's the difference between a statement ID and a fingerprint ID ?

A statement fingerprint represents one or more SQL statements by replacing literal values (e.g., numbers and strings) with underscores (_). This can help you quickly identify frequently executed SQL statements and their latencies. https://www.cockroachlabs.com/docs/stable/ui-statements-page.html#sql-statement-fingerprints

Statement ID is a unique identifier for the specific statement execution.

Copy link
Contributor

@msirek msirek 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 @andreimatei, @gtr, @j82w, @maryliag, and @yuzefovich)


pkg/sql/crdb_internal_test.go line 1002 at r6 (raw file):

			const defaultIdString = "0x0000000000000000"
			if blockingTxnId == defaultIdString {
				return fmt.Errorf("transaction_contention_events had default txn id %s, waiting txn id %s", blockingTxnId, waitingTxnId)

Change to: "transaction_contention_events had default blocking txn id..."

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 @andreimatei, @gtr, @maryliag, @msirek, and @yuzefovich)


-- commits line 11 at r3:

Previously, andreimatei (Andrei Matei) wrote…

Also, if you are to have a release note, please make it a fuller sentence that a user can understand and make use of.
I would not add a note.

I removed the note as suggested.


pkg/sql/clusterunique/id.go line 96 at r6 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

*id.Uint128 = uint128 ?

Done.


pkg/sql/contentionpb/contention.go line 95 at r2 (raw file):

Previously, gtr (Gerardo Torres Castro) wrote…

You might want to update the comment for this function. It looks like it was copied over from hashUUID().

Done.


pkg/sql/contentionpb/contention.go line 93 at r4 (raw file):

Previously, msirek (Mark Sirek) wrote…

"since uint128 is has" -> "since uint128 has"

Done.


pkg/sql/crdb_internal_test.go line 1002 at r6 (raw file):

Previously, msirek (Mark Sirek) wrote…

Change to: "transaction_contention_events had default blocking txn id..."

Done.

This adds the 'waiting_stmt_id' and 'waiting_stmt_fingerprint_id'
to the transaction_contention_events. This makes it easier for
users to figure out what the issue is when dealing with large
transactions.

part of: #91665

Release note: none
@j82w
Copy link
Contributor Author

j82w commented Feb 1, 2023

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 1, 2023

Build succeeded:

@craig craig bot merged commit b59fa09 into cockroachdb:master Feb 1, 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.

7 participants