pingcap / pingcap/tidb

tests: TestGlobalSortBasic checks cleanup results before its task is cleaned

Open
#71,097 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)

Run `TestImportInto/TestGlobalSortBasic` in `tests/realtikvtest/importintotest4` with one transient cleanup error injected through `github.com/pingcap/tidb/pkg/dxf/importinto/mockCleanupError`.

The test consumes a global `WaitCleanUpFinished` notification before checking cleanup side effects. The scheduler emits that notification even when a cleanup batch transfers zero tasks to history after a cleaner error. A notification can also belong to a different task.

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

The test waits for its own task to finish cleanup, tolerating a retry, before asserting persisted metadata redaction and file deletion.

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

Severity: minor. This is a potential test synchronization race confirmed by code inspection and local fault injection. No failure without fault injection or matching CI failure has been observed; its CI occurrence rate is unknown.

The local fault-injection run failed at the task metadata URL assertion: expected access-key and secret-access-key values `xxxxxx`, but read `aaaaaa` and `bbbbbb`. The scheduler logged `transferred-task-count=0`, `total-task-count=1`, and `batch-fully-handled=false` immediately before the assertion. The same test passed without the temporary injection.

The proposed fix is to wait, with a timeout, for each specific task to appear in `mysql.tidb_global_task_history`. A global cleanup-attempt notification does not establish that condition.

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

TiDB master at `8bccb81a1c0a81d33ebca76545e465535e374870`, tested locally against TiUP v8.5.8 in classic `tikv-slim` mode with one replica. This report is based on local fault injection, not a measured CI failure frequency.

Contributor guide

Open the contributing guide

Research direction

Start with TestImportInto/TestGlobalSortBasic in tests/realtikvtest/importintotest4 and reproduce the issue using github.com/pingcap/tidb/pkg/dxf/importinto/mockCleanupError. Trace the cleanup notification and check mysql.tidb_global_task_history for the specific task before the metadata redaction and file-deletion assertions. Done means the test tolerates a retry and waits with a timeout for its own task to finish cleanup.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.