mysql alter table add column before_MySQL online DDL重现ALTER TABLE ADD COLUMN出错

版本:

mysql> show variables like 'ver%';

+-------------------------+---------------------+

| Variable_name | Value |

+-------------------------+---------------------+

| version | 5.7.29-debug |

| version_comment | Source distribution |

| version_compile_machine | x86_64 |

| version_compile_os | Linux |

+-------------------------+---------------------+

4 rows in set (0.00 sec)

表结构:

mysql> show create table ddlutf8\G

*************************** 1. row ***************************

Table: ddlutf8

Create Table: CREATE TABLE `ddlutf8` (

`id` int(11) NOT NULL AUTO_INCREMENT,

`name` varchar(300) DEFAULT NULL,

PRIMARY KEY (`id`),

KEY `i_name` (`name`)

) ENGINE=InnoDB AUTO_INCREMENT=655351 DEFAULT CHARSET=utf8

1 row in set (0.00 sec)

mysql> show create table ddltab_bak\G

*************************** 1. row ***************************

Table: ddltab_bak

Create Table: CREATE TABLE `ddltab_bak` (

`id` int(11) NOT NULL AUTO_INCREMENT,

`name` varchar(300) DEFAULT NULL,

PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=393198 DEFAULT CHARSET=latin1

1 row in set (0.00 sec)

mysqld相关参数:

mysql> show global variables like '%online%';

+----------------------------------+---------+

| Variable_name | Value |

+----------------------------------+---------+

| innodb_online_alter_log_max_size | 8388608 |

+----------------------------------+---------+

1 row in set (0.00 sec)

mysql> show global variables like 'innodb_sort%';

+-------------------------+---------+

| Variable_name | Value |

+-------------------------+---------+

| innodb_sort_buffer_size | 1048576 |

+-------------------------+---------+

1 row in set (0.01 sec)

测试表的数据准备:

mysql> truncate table ddlutf8;

Query OK, 0 rows affected (0.71 sec)

mysql> insert into ddlutf8(name) select name from ddltab_bak;

Query OK, 262144 rows affected (42.12 sec)

Records: 262144 Duplicates: 0 Warnings: 0

实验开始。

会话一:

mysql> alter table ddlutf8 add coladded varchar(100);

迅速在另一窗口的会话二中执行:

mysql> insert into ddlutf8(name) select name from ddltab_bak;

不久,会话一alter失败,报错:

mysql> alter table ddlutf8 add coladded varchar(100);

ERROR 1799 (HY000): Creating index 'PRIMARY' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again.

会话二的insert会执行成功。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值