Skip to content

sql: the key reported by contention events is incorrect #125787

@arulajmani

Description

@arulajmani

Describe the problem

The key reported in a contention event is supposed to be the key on which there was a conflict, as per the comment here:

message ContentionEvent {
option (gogoproto.goproto_stringer) = false;
// Key is the key that this and the other transaction conflicted on.
bytes key = 1 [(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.Key"];

However, it's populated here:

BlockingEvent: kvpb.ContentionEvent{
Key: retryErr.ConflictingTxn.Key,

In doing so, we're using the key where the conflicting transaction's transaction record is anchored. See:

// key is the key which anchors the transaction. This is typically
// the first key read or written during the transaction and
// determines which range in the cluster will hold the transaction
// record.
bytes key = 3; // TODO(tschottdorf): [(gogoproto.casttype) = "Key"];

This doesn't necessarily mean that this was the key the two transactions conflicted on; just that one of the transactions wrote to this key. This seems unintentional.

Jira issue: CRDB-39609

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-observabilityRelated to observability of the SQL layerC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-observabilitybranch-masterFailures and bugs on the master branch.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions