cockroachdb / cockroachdb/cockroach

sqlstats: statements run in internal executors with outer txns have a transaction fingerprint id 0 of and no corresponding entry in txn stats

Open
#124,935 1 comment 0 reactions 0 assignees View on GitHub
C-bug T-observability
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

For statements that are run by internal executors within an outer transaction, we currently record the transaction fingerprint id as 0. These internal executors skip the transaction stats recording step which generates the transaction fingerprint id, since they are not responsible for starting or committing the outer transaction. This means we also don't have a corresponding entry in the transactions table for these internal statements.

**To Reproduce**

In any active cluster with sql stats tracking on, we can observe such statements by inspecting the sql stats statements table and searching for rows with a txn fingerprint id of 0.
```
root@localhost:26257/defaultdb> select distinct app_name from system.statement_statistics where transaction_fingerprint_id = '\x0000000000000000';
app_name
---------------------------------------------------------------
$ internal-load-job-query
$ internal-migration-job-find-already-completed
$ internal-sched-create
$ internal-read-setting
$ internal-insert-statistic
$ internal-claim-jobs
$ internal-sql-telemetry-invalid-objects
$ internal-read orphaned leases
$ internal-stmt-diag-insert
$ internal-stmt-bundle-chunks-insert
$ internal-find-running-jobs-of-type
....
```
These are all internal statements run with an outer kv txn.

**Expected behavior**
These statemetns should be given the correct transaction fingerprint id and have a corresponding transaction stats entry. Alternatively we could decide to skip recording these statements altogether.

**Environment:**
- CockroachDB version 23.1-current

Jira issue: CRDB-39155

Epic CRDB-39776

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.