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

kv: add conflicting txn_meta to error message #111937

Merged

Conversation

aadityasondhi
Copy link
Collaborator

This patch adds back the conflicting txn_meta to the error message printed out from a TransactionRetryError if available.

Fixes #110689.

Release note: None

@aadityasondhi aadityasondhi requested a review from a team as a code owner October 6, 2023 18:31
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator Author

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


-- commits line 4 at r1:
It looks like this:

TransactionRetryWithProtoRefreshError: TransactionRetryError: retry txn (RETRY_SERIALIZABLE  - failed preemptive refresh due to conflicting locks on "a" [reason=wait_policy] - conflicting txn: meta={id=628cc31a key="a" iso=Serializable pri=0.04958338 epo=0 ts=1696616855.689312000,0 min=1696616855.689312000,0 seq=1}): "original txn" meta={id=5f395c8f key="b" iso=Serializable pri=0.03612870 epo=0 ts=1696616855.689312000,1 min=1696616855.689310000,0 seq=1} lock=true stat=PENDING rts=1696616855.689310000,0 wto=false gul=1696616856.189310000,0

Copy link
Member

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

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

:lgtm:

The Cluster Observability team requires this error message to also include the conflicting txn_id for surfacing this error up to the client dashboard.

Is the db console parsing the error message instead of using the structured TransactionRetryWithProtoRefreshError proto?

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


pkg/kv/kvclient/kvcoord/dist_sender_server_test.go line 4660 at r1 (raw file):

				require.NotNil(t, tErr.ConflictingTxn)
				require.Equal(t, txn2.ID(), tErr.ConflictingTxn.ID)
				require.True(t, strings.Contains(tErr.Error(), tErr.ConflictingTxn.String()))

Would require.Regexp be a better fit?

This patch adds back the conflicting txn_meta to the error message
printed out from a `TransactionRetryError` if available.

Fixes cockroachdb#110689.

Release note: None
@aadityasondhi aadityasondhi force-pushed the 20231004.contention-txn-id-error-msg branch from 390810a to 131572b Compare October 6, 2023 19:07
Copy link
Collaborator Author

@aadityasondhi aadityasondhi left a comment

Choose a reason for hiding this comment

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

I believe this is being used to display the error as-is to the user. It also allows us to show conflicting txn in the SQL shell if this error is thrown. I would expect db console to use the actual field in the structured error for any other purpose. @xinhaoz can probably confirm.

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


pkg/kv/kvclient/kvcoord/dist_sender_server_test.go line 4660 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Would require.Regexp be a better fit?

yeah, made the change. Thanks!

@aadityasondhi
Copy link
Collaborator Author

TFTR!

bors r=nvanbenschoten

@xinhaoz
Copy link
Member

xinhaoz commented Oct 6, 2023

@aadityasondhi Yes, that's right, we won't be parsing this value at all and are reading from TransactionRetryWithProtoRefreshError. This is just helpful as an additional piece of information if for whatever reason our insights system fails to capture the conflicting txn meta / resolve the fingerprint (and can let us know to investigate why that is). There may also be other avenues they can use to correlate the txn exec id (e.g. Datadog).

Copy link
Contributor

@AlexTalks AlexTalks 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 (and 1 stale) (waiting on @nvanbenschoten)

@craig
Copy link
Contributor

craig bot commented Oct 6, 2023

Build succeeded:

@craig craig bot merged commit 5311611 into cockroachdb:master Oct 6, 2023
3 checks passed
@aadityasondhi aadityasondhi deleted the 20231004.contention-txn-id-error-msg branch October 9, 2023 18:59
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.

kv: missing conflicting txn_id in retry error message
5 participants