Bug #68139 ut_a(prebuilt->table->n_ref_count == 1) failed when DDL for mapping tables
Submitted: 22 Jan 2013 8:45 Modified: 22 Jan 2013 12:17
Reporter: hui liu (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Memcached Severity:S2 (Serious)
Version: OS:Any (5.6.9-rc)
Assigned to: CPU Architecture:Any
Tags: assertion failed; DDL; mapping tables

[22 Jan 2013 8:45] hui liu
Description:
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffd0092c700 (LWP 12407)]
0x00000038f0832a45 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00000038f0832a45 in raise () from /lib64/libc.so.6
#1  0x00000038f0834225 in abort () from /lib64/libc.so.6
#2  0x00000000009a2e9e in ha_innobase::commit_inplace_alter_table (this=0x7ffcd800b930, altered_table=0x7ffcd8013840, ha_alter_info=0x7ffd00928c10, commit=true)
    at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/storage/innobase/handler/handler0alter.cc:4786
#3  0x00000000005e8d6f in handler::ha_commit_inplace_alter_table (this=0x7ffcd800b930, altered_table=0x7ffcd8013840, ha_alter_info=0x7ffd00928c10, commit=true)
    at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/sql/handler.cc:4269
#4  0x0000000000795eec in mysql_inplace_alter_table (thd=0x123461b0, table_list=0x7ffcd80050c0, table=0x7ffcd800b050, altered_table=0x7ffcd8013840,
    ha_alter_info=0x7ffd00928c10, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, target_mdl_request=0x7ffd00929570, alter_ctx=0x7ffd00928160)
    at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/sql/sql_table.cc:6379
#5  0x000000000079948d in mysql_alter_table (thd=0x123461b0, new_db=0x7ffcd8005618 "test", new_name=0x0, create_info=0x7ffd00929fc0, table_list=0x7ffcd80050c0,
    alter_info=0x7ffd0092a0a0, order_num=0, order=0x0, ignore=false) at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/sql/sql_table.cc:8003
#6  0x00000000008a61c7 in Sql_cmd_alter_table::execute (this=0x7ffcd8005648, thd=0x123461b0) at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/sql/sql_alter.cc:313
#7  0x000000000073e4c9 in mysql_execute_command (thd=0x123461b0) at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/sql/sql_parse.cc:4839
#8  0x0000000000740b6c in mysql_parse (thd=0x123461b0, rawbuf=0x7ffcd8004fd0 "alter table t2 drop column cc", length=29, parser_state=0x7ffd0092b6b0)
    at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/sql/sql_parse.cc:6117
#9  0x00000000007360cc in dispatch_command (command=COM_QUERY, thd=0x123461b0, packet=0x1243d521 "alter table t2 drop column cc", packet_length=29)
    at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/sql/sql_parse.cc:1312
#10 0x0000000000735462 in do_command (thd=0x123461b0) at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/sql/sql_parse.cc:1036
#11 0x00000000007069a2 in do_handle_one_connection (thd_arg=0x123461b0) at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/sql/sql_connect.cc:969
#12 0x000000000070649f in handle_one_connection (arg=0x123461b0) at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/sql/sql_connect.cc:885
#13 0x0000000000bbf255 in pfs_spawn_thread (arg=0x123aa700) at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/storage/perfschema/pfs.cc:1853
#14 0x00000038f0c077e1 in start_thread () from /lib64/libpthread.so.0
#15 0x00000038f08e68ed in clone () from /lib64/libc.so.6
(gdb) f 2
#2  0x00000000009a2e9e in ha_innobase::commit_inplace_alter_table (this=0x7ffcd800b930, altered_table=0x7ffcd8013840, ha_alter_info=0x7ffd00928c10, commit=true)
    at /home/xiyu.lh/xiyu/mysql-5.6.9-rc/storage/innobase/handler/handler0alter.cc:4786
4786                    ut_a(prebuilt->table->n_ref_count == 1);
(gdb) p prebuilt->table->n_ref_count
$5 = 2

How to repeat:
## create mapping table and update the containers for default @aaa
create table test.t2 (c1 varchar(20), c2 varchar(20), PRIMARY KEY(c1));
update innodb_memcache.containers set db_table ='t2';

## keep the telnet connected
$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
get @@aaa
VALUE @@aaa 0 7
test/t2
END
set 123 0 0 3
abc
STORED

## both crashed mysqld if only SET is not closed via telnet...
alter table t2 add column cc varchar(20);
alter table t2 drop column cc;

If we close the telnet connection, then the DDL works.
[22 Jan 2013 11:18] Jimmy Yang
You will need to set --innodb_api_enable_mdl=1 if the DBA sense any possibility of concurrent DDL on the mapping table (though this could have a little performance impact). The option is by default turned off. We might consider to make it default ON
[22 Jan 2013 12:16] hui liu
Thanks for your suggestion, this option blocks the DDL as the meta-data lock takes effect:

pthread_cond_timedwait,inline_mysql_cond_timedwait,MDL_wait::timed_wait,MDL_context::acquire_lock,MDL_context::upgrade_shared_lock,mysql_inplace_alter_table,mysql_alter_table,Sql_cmd_alter_table::execute,mysql_execute_command,mysql_parse,dispatch_command,do_command,do_handle_one_connection,handle_one_connection,pfs_spawn_thread,start_thread,clone

Make it invalid since the Manual has declared: http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-txn.html
[22 Jan 2013 12:17] hui liu
Closed as a invalid bug: http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-txn.html