-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
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:
cockroach/pkg/kv/kvpb/api.proto
Lines 3661 to 3665 in 41c37cb
| 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:
cockroach/pkg/sql/conn_executor_exec.go
Lines 3365 to 3366 in c88a1ce
| 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:
cockroach/pkg/storage/enginepb/mvcc3.proto
Lines 29 to 33 in c097c19
| // 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