pingcap / pingcap/tidb

sessionctx: slow log unit test still expects retired RU V2 output

Open Beginner friendly
#70,956 0 comments 0 reactions 0 assignees View on GitHub
component/session component/test severity/minor type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

### 1. Minimal reproduce step (Required)

Run the affected session-variable unit test on `f6c6d1adba7` or a descendant:

```bash
go test ./pkg/sessionctx/variable/tests \
-run '^TestSlowLogFormatIncludesTiFlashRUInRUV2Metrics$' \
-count=1 -tags=intest,deadlock
```

The same failure is present in `pull_unit_test_ddlv1` builds [#95](https://do.pingcap.net/jenkins/job/pingcap/job/tidb/job/pull_unit_test_ddlv1/95/) and [#100](https://do.pingcap.net/jenkins/job/pingcap/job/tidb/job/pull_unit_test_ddlv1/100/).

PR #70926 intentionally replaced RU V2 slow-log values with the statement RU V3 total. However, `TestSlowLogFormatIncludesTiFlashRUInRUV2Metrics` still calls `SlowLogFormat(logItems)` without a statement RU total and expects the retired TiKV/TiFlash RU V2 total and detail output.

### 2. What did you expect to see? (Required)

The unit test should follow the current slow-log writer contract: pass an explicit statement RU total, verify that it is written through the legacy `Request_unit_v2` key, and expect the legacy detail field to be empty. The unrelated default RU V2 weight check should remain independently covered.

### 3. What did you see instead (Required)

The test fails deterministically because the no-argument formatter call omits both legacy fields:

```text
session_test.go:479: slow-log output does not contain "# Request_unit_v2: 150.00"
```

All three Bazel retry attempts fail with the same assertion. The test still expects the pre-#70926 output derived from TiKV RU `100` plus TiFlash RU `50`:

```text
# Request_unit_v2: 150.00
# Request_unit_v2_detail: total_ru:150.00, tidb_ru:0.00, tikv_ru:100.00, tiflash_ru:50.00
```

### 4. What is your TiDB version? (Required)

Current `master` after:

```text
f6c6d1adba7edae5786a4fffbacb31b1ec9c42c6
planner: add more metrics for RU V3 (#70926)
```

Locally reproduced at `fdfadb96b2cfdc5a7c26b8eb7b2a3da5f3038d85`.

Contributor guide

Open the contributing guide

Research direction

Start in session_test.go at TestSlowLogFormatIncludesTiFlashRUInRUV2Metrics and run the provided go test command to reproduce the deterministic failure. Follow the current SlowLogFormat contract from PR #70926, then update the test so it passes an explicit statement RU total, checks the legacy key and empty detail field, and keeps the default RU V2 weight check independent.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
database, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
86/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.