PolarDB for MySQL Online Copy DDL reduces business disruptions caused by traditional Copy DDL operations—such as MODIFY COLUMN or converting between standard and partitioned tables—that hold metadata locks (MDL) throughout execution.
Background
During standard Copy DDL execution, MySQL holds an MDL-SNW (Shared No Write) lock, blocking all write operations (INSERT/UPDATE/DELETE) on the table. This can cause connection buildup and, in severe cases, system collapse. Online Copy DDL optimizes the locking mechanism during the data copy phase, allowing concurrent reads and writes while maintaining data consistency.
Scope
PolarDB for MySQL version 8.0.2 and revision 8.0.2.2.33.1 or later. Confirm the cluster version by querying the version number.
Online Copy DDL is in phased release. To enable it, go to the Quota Center, find the quota by ID polarm_82_online_copy_ddl, and click **Request** in the **Operation** column. Provide the cluster ID (for example, pc-xxx).
Limitations
Supported operations:
-
Converting between standard tables and partitioned tables.
-
MODIFY COLUMNstatements. Modifying column position simultaneously is not supported.
Unsupported operations or objects:
-
Tables that contain JSON-type columns.
-
Tables that contain spatial indexes (SPATIAL INDEX).
-
Tables that contain global secondary indexes (GSI).
-
Hybrid partitioned tables.
-
Sessions that have executed
LOCK TABLESon the table. -
DDL statements that explicitly specify
ALGORITHM=COPYandLOCK=SHAREDorLOCK=EXCLUSIVE.
Before executing a DDL operation, run EXPLAIN DDL to check whether Online Copy DDL is supported.
Usage
Enable Online Copy DDL by setting the loose_polar_support_online_copy_ddl_algorithm parameter. For MODIFY COLUMN statements, also enable loose_polar_support_online_copy_ddl_algorithm_for_modify. Configure these in Set cluster parameters and node parameters.
|
Parameter |
Level |
Description |
|
|
Global |
Main switch for Online Copy DDL.
|
|
|
Global |
Enables Online Copy DDL for
|
Method 1: Explicitly Specify the Algorithm (Recommended)
Specify ALGORITHM=COPY, LOCK=NONE to force Online Copy DDL:
CREATE TABLE t(a int);
ALTER TABLE t MODIFY COLUMN a BIGINT DEFAULT NULL, ALGORITHM=COPY, LOCK=NONE;
If the statement returns ERROR 1846 (0A000): LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED., the operation does not support Online Copy DDL. Verify that loose_polar_support_online_copy_ddl_algorithm is enabled and review the limitations.
Method 2: Automatically Select the Optimal Algorithm (Default Behavior)
If no algorithm is specified or DEFAULT is used, the system selects the optimal execution method automatically:
-- Method 1: Explicit DEFAULT
ALTER TABLE t MODIFY COLUMN a BIGINT DEFAULT NULL, ALGORITHM=DEFAULT, LOCK=DEFAULT;
-- Method 2: Omit completely (equivalent)
ALTER TABLE t MODIFY COLUMN a BIGINT DEFAULT NULL;
The system attempts Online Copy DDL first. If conditions are not met, it falls back to traditional Copy DDL (which locks the table) to ensure the DDL completes.