Enable and disable lock-free schema change

更新时间:
复制 MD 格式

Before you use the lock-free schema change feature of Data Management (DMS), you must enable it for the target instance.

Prerequisites

  • Supported database types: ApsaraDB RDS for MySQL, PolarDB for MySQL, MyBase for MySQL, and MySQL from other sources.

  • The control mode of the instance is Stable Change or Security Collaboration. For more information, see View control modes.

  • You have the role of a DBA or an administrator. To view your role, see View my system roles.

Enable lock-free schema change

  1. Log in to DMS 5.0.

  2. On the console homepage, in the Database Instances list, right-click the target instance and select Lock-free Schema Change.

    Note

    Alternatively, you can go to Data Assets > Instance Management from the top menu bar. On the Instance List tab, click More > Edit to the right of the target instance, and enable lock-free schema change in the Advanced Information section.

    The following table describes the options.

    Option

    Description

    Remarks

    Enable (DMS OnlineDDL First)

    DMS uses its proprietary DDL lock-free change engine to ensure that the table is not locked.

    Note

    In the following cases, DMS OnlineDDL cannot be used, and the system automatically falls back to MySQL native OnlineDDL. The task fails if DMS detects that the native execution will lock the table or return an error.

    • The target table is empty. Native execution is used because it is faster and performing DDL on an empty table is low-risk.

    • DMS OnlineDDL does not support adding a unique constraint (UK).

    Execution is slower than MySQL native OnlineDDL, but it does not affect replication behavior and is less likely to cause replication lag.

    Enable (MySQL Native OnlineDDL First)

    DMS first tries MySQL native OnlineDDL. If DMS detects that native execution will lock tables or fail, it automatically switches to DMS OnlineDDL to prevent table locking.

    Execution is relatively fast, but it may cause the instance's parallel replication to fall back to serial replication, which can lead to replication lag.

    Close

    DMS sends the native statement directly to MySQL for execution without any processing.

    N/A

  3. In the Modify Lock-free Schema Change dialog box, click OK.

    After enabling lock-free schema change for the instance, you can submit a lock-free schema change ticket.

Disable lock-free schema change

To disable lock-free schema change, use the same entry point as enabling:

  1. On the console homepage, in the Database Instances list, right-click the target instance and select Lock-free Schema Change > Close.

    Note

    You can also choose Data Assets > Instances from the top menu bar. On the Instances tab, click More > Edit in the Actions column of the target instance, and disable lock-free schema change in the Advanced Information section.

  2. In the Modify Lock-free Schema Change dialog box, select Close, then click OK.

After you disable lock-free schema change, DMS sends native DDL statements directly to MySQL for execution without any processing. Whether tables are locked during schema changes depends on the database engine's Online DDL support:

  • If the database supports Online DDL, the DDL operation holds only a brief metadata lock and does not lock the table for an extended period.

  • If the database does not support Online DDL, the table is locked for the duration of the DDL operation.

Note

Disabling or re-enabling lock-free schema change requires no instance restart and does not affect instance status or data. This setting only applies to schema change tickets submitted through DMS and does not affect DDL statements executed directly by other clients.

Related operations

After you enable lock-free schema change for an instance, DMS prioritizes this method for the following types of tickets on that instance:

FAQ

Does disabling and re-enabling DMS lock-free schema change have any impact?

No. Disabling and re-enabling the lock-free schema change option does not affect instance status or data, requires no instance restart, and poses no data risk. During the period when lock-free schema change is disabled, DMS uses native DDL to execute schema changes. After you re-enable lock-free schema change, DMS resumes using its lock-free schema change engine for schema change tickets submitted through DMS.