cockroachdb / cockroachdb/cockroach

concurrency: fix discrepancies with with lock observability

Open
#103,894 0 comments 0 reactions 0 assignees View on GitHub
C-bug T-kv
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

There's a few discrepancies in lock metrics/observability that could use some re-imagination. Some are a result of removing the concept of reservations, over in https://github.com/cockroachdb/cockroach/pull/103478, and others were found along the way. This issue serves as a single place to track these. We may want to split these out into separate issues in the future.

1. `LockTableMetrics` currently tracks reservations separately. However, now that we don't have such a concept, reservations are no different from inactive waiting writers. As such, we should get rid of this tracking entirely.

2. `totalAndMaxWaitDuration`, which is responsible for calculating the total and maximum wait time for waiters waiting on a lock, does not make a distinction between active and inactive waiters. Arguably, it should -- we should only consider requests actively waiting at a lock in this calculation. In practice, this only applies to waiting writers, as there's no such thing as inactive readers. See around:
https://github.com/cockroachdb/cockroach/blob/4f900869fbe1eb17b294eaf32ba5800b50d0cff4/pkg/kv/kvserver/concurrency/lock_table.go#L1491-L1501C3

3. `collectLockStateInfo` conditionally includes uncontended locks. However, the determination to consider a lock contended or uncontended does not take active/inactive status into account. Arguably, it should. See around: https://github.com/cockroachdb/cockroach/blob/4f900869fbe1eb17b294eaf32ba5800b50d0cff4/pkg/kv/kvserver/concurrency/lock_table.go#L1155-L1158

Specifically, if there are writers, but all writers are inactive, then the lock should be considered uncontended.

cc @AlexTalks

Jira issue: CRDB-28245

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.