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.
- 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.
|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.
Submit a lock-free DDL ticket
- Go to the DMS console V5.0.
- In the top navigation bar, click Database Development. In the left-side navigation pane, choose .
- On the Data Change Ticket Application page, set the parameters described in the following
Parameter Description Database Select the database in which you want to perform a schema change from the Database drop-down list. You can also enter a keyword to search for the database.Note You must have the permissions to perform schema changes on the required database. For more information, see View owned permissions. SQL Statements for Change Enter DDL statements in the field, such as
OPTIMIZEstatements.Note You can also enter DML statements to perform lock-free DML operations. For more information, see Perform lock-free DML operations.
- Click Submit. DMS prechecks the SQL statements. If the precheck fails, click SQL Statements for Modification to modify the SQL statements and try again.
- After the ticket is approved, click Execute Change in the Execute step. Note On the Ticket Details page, you can view the approval progress in the Approval step.
- Set the parameter for the task.
Parameter Description Execution Strategy
- Running immediately: This is the default value. After you click Confirm Execution, the task is immediately run.
- Schedule: If you select this option, you must specify the start time for the task. After you click Confirm Execution, the task is run at the specified point in time.
- Click Confirm Execution.
- You can view the execution status, settings, and details of the task in the Execute step. You can also view the scheduling logs.
- Alternatively, you can click Task Management. Then, find the task and view the task progress. For more information, see View the progress of a lock-free change task. in the top navigation bar. In the left-side navigation pane, click