Data Management (DMS) provides the lock-free DDL feature. You can use this feature to change schemas without the need to lock tables. This prevents your business from being affected by table locking that is caused by schema changes. This also prevents the synchronization latency between primary and secondary databases from occurring when schemas are changed by using native online DDL operations. This topic describes how to perform a lock-free DDL operation.
Prerequisites
- The database type is ApsaraDB RDS for MySQL, PolarDB for MySQL, MyBase for MySQL, or MySQL database from other sources.
- The database engine is InnoDB, RocksDB, or X-Engine.
- The database instance is managed in Stable Change or Security Collaboration mode in DMS. For more information, see View the control mode of an instance.
- The lock-free schema change feature is enabled for the database instance. For more information, see Enable the lock-free schema change feature.
Limits
Item | Description |
---|---|
Database account |
Note
|
Disk space | Make sure that the database in which you perform the lock-free DDL operation has sufficient
disk space. This is because the database needs to create a temporary table and copy
the data of the original table to the temporary table.
Note If the disk space of the database instance is insufficient, the instance will be locked.
|
Log format | Enable the binary logging feature.
Note By default, the binary logging feature is disabled for PolarDB. For more information
about how to enable the binary logging feature for PolarDB, see Enable binary logging.
|
Primary key or unique key of the original table | To perform a lock-free DDL operation on a table, make sure that the table contains
a primary key or unique key. The primary key or unique key is used to copy all or
part of data from the table and synchronize incremental data.
|
Table name length | The table name can be at most 56 characters in length. |
Methods to perform lock-free schema changes
- Submit a schema design ticket. For more information, see Schema design.
- Submit a schema synchronization ticket. For more information, see Synchronize schemas.
- Submit a shadow table synchronization ticket. For more information, see Synchronize shadow tables.
- Submit an empty database initialization ticket. For more information, see Initialize empty databases.
- Submit a table consistency repair ticket. For more information, see Repair table consistency.
- Submit a lock-free DDL ticket to change the schema of a table. For more information, see Submit a lock-free DDL ticket.
- Submit a regular data change ticket to change the schema of a table. For more information, see Change regular data.