pingcap / pingcap/tidb

tests: TestNextGenMetering rejects valid zero-second task durations

Open Beginner friendly
#71,098 0 comments 0 reactions 0 assignees View on GitHub
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)

`TestNextGenMetering` in `tests/realtikvtest/importintotest4` asserts that `duration_seconds > 0` for a small three-row import. Consider a successful task whose recorded start/end duration is less than one second.

Production code in `pkg/dxf/framework/handle/handle.go` calculates the value as `int64(task.StateUpdateTime.Sub(task.CreateTime).Seconds())`, which truncates a positive sub-second duration to zero.

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

The metering assertion accepts a non-negative integer duration, including zero. The analogous assertion in `tests/realtikvtest/addindextest2` was fixed in #68453.

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

Severity: minor. The zero-second boundary follows from the integer-duration calculation, but no matching failure or high-probability triggering has been established for this test in CI. A full local NextGen run has not been performed.

A valid zero value cannot satisfy the polling condition, so the assertion will time out after 30 seconds. Waiting longer does not change the duration of an already completed task.

This is a code-confirmed boundary condition; a full local NextGen reproduction is not available. The separate nil-pointer polling issue is already covered by #69217 and is outside this issue's scope.

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

TiDB master at `8bccb81a1c0a81d33ebca76545e465535e374870`, NextGen test path.

Contributor guide

Open the contributing guide

Research direction

Start with TestNextGenMetering in tests/realtikvtest/importintotest4 and compare its duration polling assertion with the analogous fix in tests/realtikvtest/addindextest2. Review pkg/dxf/framework/handle/handle.go to confirm the integer duration behavior, then run the focused test; it is done when valid completed tasks with zero-second durations satisfy the assertion without a timeout.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.