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

Online DDL engine cannot handle partitioned tables, so declarative migrations cannot be used #9220

Closed
aquarapid opened this issue Nov 13, 2021 · 1 comment
Labels
Type: Enhancement Logical improvement (somewhere between a bug and feature)

Comments

@aquarapid
Copy link
Contributor

Scenario:

  • Unsharded keyspace
  • Recent main branch
  • issue repro:
mysql> use unsharded;
Database changed
mysql> SET @@ddl_strategy='online';                                 
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t1 (     username VARCHAR(20) NOT NULL,     logdata BLOB NOT NULL,     created DATETIME NOT NULL,     PRIMARY KEY(username, created) ) PARTITION BY HASH( TO_DAYS(created) ) PARTITIONS 10;
ERROR 1149 (42000): syntax error at position 166 near 'PARTITION'
mysql> SET @@ddl_strategy='direct';                                                                    
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t1 (     username VARCHAR(20) NOT NULL,     logdata BLOB NOT NULL,     created DATETIME NOT NULL,     PRIMARY KEY(username, created) ) PARTITION BY HASH( TO_DAYS(created) ) PARTITIONS 10;
Query OK, 0 rows affected (0.08 sec)

mysql> show create table t1\G
*************************** 1. row ***************************
     Table: t1
Create Table: CREATE TABLE `t1` (
`username` varchar(20) NOT NULL,
`logdata` blob NOT NULL,
`created` datetime NOT NULL,
PRIMARY KEY (`username`,`created`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
/*!50100 PARTITION BY HASH (to_days(`created`))
PARTITIONS 10 */
1 row in set (0.00 sec)
  • Commentary:
    • When DDL is executed directly (mode direct), table creation with partitions work fine
    • With DDL strategy online, we get a syntax error. This is because of the additional checks in onlineDDLStatementSanity(..) in go/vt/schema/online_ddl.go that depends on the DDL being fully parsed by the Vitess sqlparser.
    • For the regular CREATE TABLE flow, this is not normally a problem, since the initial CREATE TABLE can be run with direct mode. However, if the user wants to use declarative online DDL (https://vitess.io/docs/user-guides/schema-changes/declarative-migrations/), they are out of luck.
@aquarapid aquarapid added the Type: Enhancement Logical improvement (somewhere between a bug and feature) label Nov 13, 2021
@aquarapid
Copy link
Contributor Author

#8691 (merged) fixes this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

No branches or pull requests

1 participant