Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mjonss opened this issue Feb 9, 2024 · 1 comment · Fixed by #51631
Labels
affects-7.5 component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@mjonss
Copy link
Contributor

mjonss commented Feb 9, 2024

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
@mjonss mjonss added type/bug The issue is confirmed as a bug. component/tablepartition This issue is related to Table Partition of TiDB. labels Feb 9, 2024
@mjonss
Copy link
Contributor Author

mjonss commented Mar 12, 2024

ALTER TABLE t PARTITION BY ... is a new feature released in v7.5, so does not affect earlier versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants