cockroachdb / cockroachdb/cockroach
obs: expose max_execution_latency through SQL builtin and HTTP API
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Is your feature request related to a problem? Please describe.**
The backend infrastructure for `max_execution_latency` on statement diagnostics requests has landed. The registry, filtering logic, validation, version gate, and schema migration are all in place — but users currently have no way to set the value. Both entry points hardcode `0`:
- `request_statement_bundle()` builtin passes `0` for `maxExecutionLatency` (`pkg/sql/sem/builtins/builtins.go:12981`)
- `CreateStatementDiagnosticsReport` HTTP API omits the field from the protobuf message (`pkg/server/statement_diagnostics_requests.go:100`)
**Describe the solution you'd like**
1. **SQL Builtin** (`pkg/sql/sem/builtins/builtins.go`)
- Add new overloads to `request_statement_bundle` that accept a `maxExecutionLatency` interval parameter (positioned after `minExecutionLatency`, before `expiresAfter`)
- Extract the value and pass it through the call chain instead of `0`
- Register new OIDs in `fixed_oids.go`
2. **Protobuf API** (`pkg/server/serverpb/status.proto`)
- Add `max_execution_latency` field to `CreateStatementDiagnosticsReportRequest`
- Wire it through in `statement_diagnostics_requests.go` instead of passing `0`
- Regenerate protobuf
Example usage after this change:
```sql
SELECT crdb_internal.request_statement_bundle(
'SELECT * FROM orders WHERE customer_id = $1',
1.0, -- samplingProbability
'100ms'::INTERVAL, -- minExecutionLatency
'500ms'::INTERVAL, -- maxExecutionLatency (NEW)
'24h'::INTERVAL -- expiresAfter
);
```
**Describe alternatives you've considered**
The DB Console UI also needs a max latency input field in the activate diagnostics modal, but that will be handled in a separate follow-up issue.
**Additional context**
Informs #161004
Jira issue: CRDB-58656
Jira issue: CRDB-62909
Contributor guide
Assessment
This issue has not been assessed yet.