pingcap / pingcap/tidb

dropping fk index in ddl rollback cause inifinite loop

Open
#66,650 1 comment 0 reactions 1 assignee Claimed by @YangKeao View on GitHub
component/ddl may-affects-7.1 may-affects-7.5 may-affects-8.1 may-affects-8.5 severity/major type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```
-- Build the FK-without-other-coverage state:
CREATE TABLE parent (id INT PRIMARY KEY);
CREATE TABLE child (id INT PRIMARY KEY, col INT);

-- Add FK (auto-creates INDEX fk1 + FK fk1)
ALTER TABLE child ADD CONSTRAINT fk1 FOREIGN KEY (col) REFERENCES parent(id);
-- Add alternate coverage
ALTER TABLE child ADD INDEX fk1_alt (col);
-- Drop auto-index (fk1_alt covers it)
ALTER TABLE child DROP INDEX fk1;
-- Now: only fk1_alt covers FK fk1

-- Fill with data to make DDL slow (so ADMIN CANCEL has time to fire)
-- (Use a generator or INSERT ... SELECT to create ~1M rows)

-- Session 1: Start this DDL
ALTER TABLE child ADD INDEX new_covering (col);
-- (no DROP INDEX here — can't drop fk1_alt while it's the only coverage)

-- Session 2: Cancel before it completes
-- ADMIN SHOW DDL JOBS 5\G
-- ADMIN CANCEL DDL JOBS ;
```
### 2. What did you expect to see? (Required)

job being canceled

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

rollback stuck in a infinite loop

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

master

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.