首页 > 数据库 > MySQL > 线上online ddl不生效
遇到了线上集群online ddl不生效的问题,本应该使用inplace的走了copy.
看了下代码,一开始看的是is_inplace_alter_imppossible,因为从名字来看就是判断是否能使用inplace的,但是看了一圈,夜没发现什么有用的信息,后面退出来看了mysql_alter_table中的流程,发现也有判断是否使用inplace的逻辑
/*
Use copy algorithm if:
- old_alter_table system variable is set without in-place requested using
the ALGORITHM clause.
- Or if in-place is impossible for given operation.
- Changes to partitioning which were not handled by
fast_alter_partition_table() needs to be handled using table copying
algorithm unless the engine supports auto-partitioning as such engines
can do some changes using in-place API.
*/
if ((thd->variables.old_alter_table &&
alter_info->requested_algorithm !=
Alter_info::ALTER_TABLE_ALGORITHM_INPLACE)
|| is_inplace_alter_impossible(table, create_info, alter_info, &alter_ctx)
|| (partition_changed &&
!(table->s->db_type()->partition_flags() & HA_USE_AUTO_PARTITION))
)
{
if (alter_info->requested_algorithm ==
Alter_info::ALTER_TABLE_ALGORITHM_INPLACE)
{
my_error(ER_ALTER_OPERATION_NOT_SUPPORTED, MYF(0),
"ALGORITHM=INPLACE", "ALGORITHM=COPY");
DBUG_RETURN(true);
}
alter_info->requested_algorithm= Alter_info::ALTER_TABLE_ALGORITHM_COPY;
}
检查了下对应的参数,果然是参数设置引起的问题。
为什么相关逻辑不放到同一个函数下统一处理? 还单拎出来判断。。。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25719946/viewspace-2944468/ ,如需转载,请注明出处,否则将追究法律责任。