[MySQL Bug]对一个已经discard tablespace的表做DDL导致crash

————————————————–

BugMySQL的内部版本号为bug13943231,并且很容易触发该BUG

1.Test case

create table t1(c1 int) engine=innodb;
alter table t1 discard tablespace;
alter table t1 add unique index(c1);

2.原因:
MySQLdiscard tablespace操作实际上已经删除了.ibd文件,但在innodb层并没有判断该行为,而是继续执行下去,因此很快就触发断言失败,以下是一次crashbacktrace

(gdb) f 2
#2 0x000000000089a39b in fil_space_get_latch (id=5988266, flags=0x4a20ed20)
at /home/yinfeng.zwx/project/PS5518/trunk/Percona-Server-5.5.18/storage/innobase/fil/fil0fil.c:537
537 ut_a(space);
(gdb) l
532
533 mutex_enter(&fil_system->mutex);
534
535 space = fil_space_get_by_id(id);
536
537 ut_a(space);
538
539 if (flags) {
540 *flags = space->flags;
541 }
(gdb) p space
$1 = (fil_space_t *) 0x0

#2 fil_space_get_latch
#3 fseg_create_general
#4 btr_create
#5 dict_create_index_tree_step
#6 dict_create_index_step
#7 que_thr_step
#8 que_run_threads_low
#9 que_run_threads
#10 row_merge_create_index_graph
#11 row_merge_create_index
#12 ha_innobase::add_index

3.修复(来自官方)

修复的方法很简单,就是在add_index时判断是否已经discard tablespace了,如果是,就返回错误。

=== modified file ‘storage/innobase/handler/handler0alter.cc’
— storage/innobase/handler/handler0alter.cc   2012-02-28 12:04:21 +0000
+++ storage/innobase/handler/handler0alter.cc   2012-05-16 11:03:22 +0000
@@ -708,6 +708,10 @@

ut_a(indexed_table == prebuilt->table);

+       if (indexed_table->tablespace_discarded) {
+               DBUG_RETURN(-1);
+       }
+
/* Check that index keys are sensible */
error = innobase_check_index_keys(key_info, num_of_keys, prebuilt->table);

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值