Skip to content

ALTER TABLE t PARTITION BY KEY(a) leaves the table in an intermediate state if DDL is cancelled #51090

@mjonss

Description

@mjonss

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t;
CREATE TABLE t (
  a int unsigned NOT NULL AUTO_INCREMENT,
  b varchar(255) DEFAULT NULL,
  PRIMARY KEY (a),
  KEY (b)
);

insert into t values (1,1),(2,2),(3,3),(4,4);
-- 1k
insert into t select null, t2.a from t, t t1, t t2, t t3, t t4;
-- 1M
insert into t select null, t2.a from t, t t2;

alter table t partition by key(b) partitions 100;
-- Wait until it shows as running, start a new session
-- check with admin show ddl jobs;
-- then
admin cancel ddl jobs <JOB_ID from above>;

-- Then the table is left in an intermediate state:
show create table t;

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

Table rollbacked as previous state, non-partitioned

3. What did you see instead (Required)

Table is in an intermediate state, technically partitioned, but only with one partition and partitioned by NONE()

tidb> show create table t\G
*************************** 1. row ***************************
       Table: t
Create Table: CREATE TABLE `t` (
  `a` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `b` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */,
  KEY `b` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=1730010
PARTITION BY NONE ()
(PARTITION `pFullTable` COMMENT 'Intermediate partition during ALTER TABLE ... PARTITION BY ...')
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

tidb_version(): Release Version: v8.0.0-alpha-235-ga29bbb5ca1
Edition: Community
Git Commit Hash: a29bbb5ca180177b532d05283970ae17fc866ee9
Git Branch: master
UTC Build Time: 2024-02-09 12:49:36
GoVersion: go1.21.0
Race Enabled: false
Check Table Before Drop: false
Store: unistore

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions