innodb_online_alter_log_max_size导致的innodb添加字段时
报错
innodb_online_alter_log_max_size这个参数是mysql 5.6.6引⼊的,因为在online ddl过程中需要保持delete、update、insert这些数
mysql操作官方文档
据,所以需要⼀个⽇志去保持,这个参数就是限制这个⽇志的最⼤⼤⼩,当ddl过程中需要的这个⽇志的⼤⼩⽐这个限制还⼤的时候就会报
错。
具体的错误:
ERROR 1799 (HY000) at line 1: Creating index 'PRIMARY' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again.
解决⽅法:
该参数为动态参数且全局的,可通过如下命令加⼤(不⼀定是我下⾯设置的⼤⼩,这个根据你的情况)
mysql> set global innodb_online_alter_log_max_size=402653184;
5.7中的官⽅⽂档关于这个参数的解释:
innodb_online_alter_log_max_size
Command-Line Format--innodb_online_alter_log_max_size=#
System Variable Name
Variable Scope Global
Dynamic Variable Yes
Permitted Values Type integer
Default134217728
Min Value65536
Max Value2**64-1
Specifies an upper limit on the size of the temporary log files used during  operations for InnoDB tables. There is one such log file for each
index being created or table being altered. This log file stores data inserted, updated, or deleted in the table during the DDL operation. The temporary log file is extended when needed by the value of , up to the maximum specified by innodb_online_alter_log_max_size. If any temporary
log file exceeds the upper size limit, the  operation fails and all uncommitted concurrent DML operations are rolled back. Thus, a large
value for this option allows more DML to happen during an online DDL operation, but also causes a longer period at the end of the DDL operation when the table is locked to apply the data from the log.
online ddl的原理是,mysql把在ddl时间内的所有的插⼊,更新和删除操作记录到⼀个⽇志⽂件,然后再把这些增量数据应⽤到相应的表上(等表上的事务完全
释放后),这个临时⽇志⽂件的上限值由innodb_online_alter_log_max_size指定,每次扩展innodb_sort_buffer_size的⼤⼩该参数如果太⼩有可能导致DDL失
败,这期间所有的未提交的并发DML操作都会回滚;但是如果太⼤会可能会导致后DDL操作最后锁定
表的时间更长(锁定表,应⽤⽇志到表上)。每⼀个变化
的索引或者表都会分配⼀个。
关于更多的online ddl可以看看5.6和5.7的官⽅⽂档。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。