cockroachdb / cockroachdb/cockroach

sql: track self-induced latch wait time as a separate metric

Open
#124,068 0 comments 0 reactions 0 assignees View on GitHub
A-sql-observability C-enhancement T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

We already have a `contention time` metric which is visible in statement bundles and statement statistics. This includes time spent waiting on another transaction in the lock table and (after https://github.com/cockroachdb/cockroach/pull/113649) in the latch table. However, the latch table is also used to wait on requests issued by the _current_ transaction. QueryIntent requests are an example of this; they are used to wait until a pipelined write has finished replicating. Since the cause and mitigation for high self-induced latch wait time is different from contention time, it is not included in the `contention time` metric.

This issue tracks adding a separate metric for self-induced latch wait time. Note that after https://github.com/cockroachdb/cockroach/pull/113649 merges, self-induced latch wait events will be visible in the trace as lines like `event:latch table conflict with 285e526b-1cbe-41d7-982b-bb043762410a on /Table/106/1/0/0 for 0.909s`.

Jira issue: CRDB-38684

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing contention time metric through statement bundles and statement statistics, using the described latch-table trace events and QueryIntent requests as the behavioral reference. Define completion as a separate metric for self-induced latch wait time that is not included in contention time, and verify its visibility in the relevant statistics surfaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.