pingcap / pingcap/tidb

PLAN REPLAYER LOAD fails with "Unknown database" when the dump was taken with tidb_low_resolution_tso enabled

Open
#71,124 0 comments 0 reactions 0 assignees View on GitHub
affects-26.3 affects-8.5 severity/moderate sig/planner 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)

On cluster A (the dumping side):

```sql
create table t(a int, b int, index idx_a(a));
set @@tidb_low_resolution_tso = 1;
plan replayer dump explain select * from t where a = 1;
```

Download the zip. Its `variables.toml` contains `tidb_low_resolution_tso = "ON"`.

On cluster B (the loading side), with `mysql --local-infile=1`:

```sql
plan replayer load '/path/to/dump.zip';
```

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

The load succeeds, or at least reports the real reason it cannot create the schema.

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

```
ERROR 1049 (42000): Unknown database 'test'
```

Root cause: `PLAN REPLAYER LOAD` applies every variable from `variables.toml` to the loading session before it creates the schema. With `tidb_low_resolution_tso` on, TiDB rejects the `create database if not exists` DDL with "can not execute write statement when 'tidb_low_resolution_tso' is set". `createSchemaAndItems` in `pkg/executor/plan_replayer.go` logs that error only at debug level and continues, so the following `use ` fails with "Unknown database", which hides the actual cause.

`tidb_snapshot` and `tidb_read_staleness` in the dump cause the same class of problem: they override the read timestamp of the loading session, either rejecting the DDL or making the freshly created schema invisible to a stale infoschema.

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

Reproduced on v8.5.7 and current master (e73d535e34).

Contributor guide

Open the contributing guide

Research direction

Start in pkg/executor/plan_replayer.go at createSchemaAndItems and reproduce the dump/load sequence using tidb_low_resolution_tso, tidb_snapshot, or tidb_read_staleness. Trace how variables.toml values are applied before schema creation and how schema-creation errors are logged. Done means PLAN REPLAYER LOAD no longer hides the schema-creation failure behind "Unknown database" and reports the real cause or loads successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
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.