This topic describes the non-blocking DDL feature of RDS for MySQL.
MySQL 8.0, and the kernel minor version of MySQL 8.0.43_20260815 and above.
In MySQL, DDL operations must acquire the MDL lock on the target table to commit metadata changes and ensure metadata consistency. MDL locks are incompatible with locks of any other type. If the DDL thread enters the pending state because it cannot acquire the lock immediately, all subsequent accesses to the target table will be blocked, which may cause business system failures and unavailability.
After non-blocking DDL is enabled, for DDL threads that need to upgrade to an MDL lock, the system attempts to acquire the lock through intermittent retries while waiting for the MDL lock and does not block continuously. Between two attempts to acquire the lock, business DDL operations can still continue to execute.
- Enabling the non-blocking DDL feature reduces the priority of DDL. Therefore, the probability of DDL failures caused by the inability to acquire the MDL lock increases.
- Only ALTER TABLE, CREATE INDEX and DROP INDEX operations are currently supported.
- RENAME TABLE cannot be executed directly.
- It does not take effect in the slave_thread scenario.
You can enable and adjust the non-blocking DDL feature through the loose_rds_nonblock_ddl_retry_interval and loose_rds_nonblock_ddl_lock_wait_timeout parameters.
- Instance specification: RDS for MySQL 4C8G.
- Instance version: MySQL 8.0.
- Create tables and insert data through sysbench.
- Start the sysbench stress test to simulate online business.
- Start session 1 and open a long-running transaction on the target table, to block subsequent DDL operations on this table.
- Start another session 2 and execute the DDL operation with the non-blocking DDL feature disabled.
- Enable the non-blocking DDL feature, and set the loose_rds_nonblock_ddl_retry_interval parameter to 6 and the loose_rds_nonblock_ddl_lock_wait_timeout parameter to 1. Execute the same DDL operation as in the previous step.
The test results are as follows.
The following conclusions can be drawn from the comparison figure below:
- When the non-blocking DDL feature is disabled, the DDL thread cannot acquire the MDL lock, and the session is fully blocked.
- When the non-blocking DDL feature is enabled, the DDL thread can acquire the MDL lock intermittently, and the session is not fully blocked.