inplace mysql,MySQL 5.6-即使使用ALGORITHM = inplace,表也会锁定

I'm running the following ALTER command on a MySQL 5.6 database on a large table with 60 million rows:

ALTER TABLE `large_table` ADD COLUMN `note` longtext NULL,

ALGORITHM=INPLACE, LOCK=NONE;

Despite specifying both ALGORITHM=INPLACE and LOCK=NONE, the table gets locked and essentially takes down the app until the migration is complete.

I verified that the table was indeed locked by checking the value of the In_use column on the output of the SHOW OPEN TABLES command. It was set to 1.

From what I gather in the MySQL documentation, this operation should not be locking the table. And, MySQL is supposed to fail the command if it is not able to proceed without a lock. I upgraded the database to MySQL 5.7 to see if it's any better, but I face the same problem on 5.7 too.

Is this an expected behavior? How do I find out what's going wrong here?

解决方案

I assume you were not doing some other DDL on that table at about the same time?

For the future:

8.0.12 has ALTER TABLE .. ALGORITHM=INSTANT for ADD COLUMN. See Discussion and ALTER Reference and Online DDL Reference

The following limitations apply when the INSTANT algorithm is used to add a column:

Adding a column cannot be combined in the same statement with other ALTER TABLE actions that do not support ALGORITHM=INSTANT.

A column can only be added as the last column of the table. Adding a column to any other position among other columns is not supported.

Columns cannot be added to tables that use ROW_FORMAT=COMPRESSED.

Columns cannot be added to tables that include a FULLTEXT index.

Columns cannot be added to temporary tables. Temporary tables only support ALGORITHM=COPY.

Columns cannot be added to tables that reside in the data dictionary tablespace.

Row size limits are not evaluated when adding a column. However, row size limits are checked during DML operations that insert and update rows in the table.

Multiple columns may be added in the same ALTER TABLE statement.

If you can't upgrade then consider Percona's pt-online-schema-change or a new, competing, product gh-ost (which uses the binlog).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值