Skip to content

kvpb: add ConflictKey field to propagate actual conflict key#162545

Open
angles-n-daemons wants to merge 1 commit intocockroachdb:masterfrom
angles-n-daemons:contention-event-proper-key
Open

kvpb: add ConflictKey field to propagate actual conflict key#162545
angles-n-daemons wants to merge 1 commit intocockroachdb:masterfrom
angles-n-daemons:contention-event-proper-key

Conversation

@angles-n-daemons
Copy link
Contributor

Previously, contention events incorrectly reported the anchor key (TxnMeta.Key) instead of the actual conflict key. The anchor key is where a transaction's record is stored, which is often different from the key where the conflict occurred.

This change adds a ConflictKey field to TransactionRetryError and TransactionRetryWithProtoRefreshError to propagate the actual conflict key from RefreshFailedError through the error chain. The SQL layer now uses this field when recording SERIALIZATION_CONFLICT contention events.

Fixes #125787

Release note (bug fix): Fixed a bug where contention events reported the wrong key. Previously, the key field in contention events showed the transaction's anchor key (used for record placement) rather than the actual key where the conflict occurred. This made it difficult to diagnose contention issues accurately.

(co-authored with claude)

Previously, contention events incorrectly reported the anchor key
(TxnMeta.Key) instead of the actual conflict key. The anchor key is
where a transaction's record is stored, which is often different from
the key where the conflict occurred.

This change adds a ConflictKey field to TransactionRetryError and
TransactionRetryWithProtoRefreshError to propagate the actual conflict
key from RefreshFailedError through the error chain. The SQL layer now
uses this field when recording SERIALIZATION_CONFLICT contention events.

Fixes cockroachdb#125787

Release note (bug fix): Fixed a bug where contention events reported
the wrong key. Previously, the key field in contention events showed
the transaction's anchor key (used for record placement) rather than
the actual key where the conflict occurred. This made it difficult to
diagnose contention issues accurately.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@trunk-io
Copy link
Contributor

trunk-io bot commented Feb 5, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

@blathers-crl
Copy link

blathers-crl bot commented Feb 5, 2026

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@angles-n-daemons angles-n-daemons marked this pull request as ready for review February 5, 2026 16:53
@angles-n-daemons angles-n-daemons requested a review from a team as a code owner February 5, 2026 16:53
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.

sql: the key reported by contention events is incorrect

2 participants