Skip to content

Cancel add index job may cause incorrect schema state #43323

@tangenta

Description

@tangenta

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. Execute CREATE INDEX.
  2. Wait for a while and execute ADMIN CANCEL DDL JOBS n.

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

The create index job should be canceled normally.

3. What did you see instead (Required)

ERROR 1105 (HY000): When the state is JobStateRollbackDone or JobStateCancelled, historyJob.Error should never be nil

When I create the same index:

ERROR 1061 (42000): index already exist idx; a background job is trying to add the same index, please check by `ADMIN SHOW DDL JOBS
mysql> admin show ddl jobs 1;
+--------+---------+------------+------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+-----------+
| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE               | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | CREATE_TIME         | START_TIME          | END_TIME            | STATE     |
+--------+---------+------------+------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+-----------+
|     95 | sbtest  | sbtest1    | add index /* ingest */ | delete only  |        88 |       90 |  13332166 | 2023-04-23 15:41:25 | 2023-04-23 15:41:25 | 2023-04-23 15:41:46 | cancelled |
+--------+---------+------------+------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+-----------+

4. What is your TiDB version? (Required)

9825089

Metadata

Metadata

Assignees

Labels

affects-7.1This bug affects the 7.1.x(LTS) versions.severity/majortype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions