release-23.1: kv/concurrency: compute contention event duration from (key,txn) wait start time #99928
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 1/1 commits from #99166 on behalf of @nvanbenschoten.
/cc @cockroachdb/release
Fixes #98104.
This commit resolves the bug identified in #98104 where multiple contention events could be emitted with overlapping durations, such that when these durations were added together (e.g. by
GetCumulativeContentionTime
), their sum was larger than the runtime of the entire query. This was possible because as of 70ef641, we were failing to reset the waiting start time on each new lock holder transaction for the same key.This commit fixes this by computing the contention event duration using
contentionTag.waitStart
instead ofwaitingState.lockWaitStart
. It also cleans up some of this code and makes it harder to make such a mistake in the future.Release note: None
Release justification: observability fix