Bug #68224 mysqld crash when querying key_column_usage if ndb foreign keys defined
Submitted: 30 Jan 2013 10:39 Modified: 23 Feb 2013 11:30
Reporter: Sébastien Barré Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S1 (Critical)
Version:7.3.0 OS:Windows (Server 2008 R2 64-bit)
Assigned to: CPU Architecture:Any

[30 Jan 2013 10:39] Sébastien Barré
Description:
mysqld crashes if we make use of the recent support for foreign keys on ndb tables and try a simple select on information_schema.key_column_usage. In order to narrow down the bug as much as possible, we made other trials with following results:
-if no ndb foreign key is defined and we do a select on information_schema.key_column_usage, no crash happens.
-ndb primary keys do not hurt either.
-ndb foreign keys cause a mysqld crash with 100% reproductibility.

Since we are on windows and ndb_error_reporter looks designed for Linux, we describe here the config of our test cluster:
-three hosts used, 10.1.1.34 with mysqld and ndbd, 10.1.1.36 with mysqld and ndbd (using replication) and 10.1.1.37 with ndb_mgmd.
-my.ini on 10.1.1.34:
[mysqld]
ndbcluster                      # run NDB storage engine
[mysql_cluster]
ndb-connectstring=10.1.1.37  # location of management server

-my.ini on 10.1.1.36: just the same as the one on 10.1.1.34
-my.ini on 10.1.1.37:
[ndb_mgmd]
config_file=C:/Program Files/MySQL/MySQL Server 5.5/mysql-cluster/config.ini
-config.ini on 10.1.1.37:
[ndbd default]
NoOfReplicas=2
DataDir=C:/Program Files/MySQL/MySQL Server 5.5/cluster-data
DataMemory=80M
IndexMemory=18M
[ndb_mgmd]
DataDir=C:/Program Files/MySQL/MySQL Server 5.5/cluster-logs
HostName=10.1.1.37
NodeId = 1
[ndbd]
HostName=10.1.1.34
NodeId = 11
[ndbd]
HostName=10.1.1.36
NodeId = 12
[mysqld]
HostName=10.1.1.34
NodeId = 21
[mysqld]
HostName=10.1.1.36
NodeId = 22

How to repeat:
mysql>select * from information_schema.key_column_usage;
[...] (table successfully displayed as no foreign key is defined yet)
mysql> create table fktest (id int primary key) engine=ndb;
Query OK, 0 rows affected (0.25 sec)
mysql> create table fktest2 (id int, foreign key(id) references fktest(id)) engine=ndb;
Query OK, 0 rows affected (0.19 sec)
mysql> select * from information_schema.key_column_usage;
[mysqld crash]

mysqld dump:

.\mysqld.exe --console --verbose
130130 11:31:04 [Note] Plugin 'FEDERATED' is disabled.
130130 11:31:04 InnoDB: The InnoDB memory heap is disabled
130130 11:31:04 InnoDB: Mutexes and rw_locks use Windows interlocked functions
130130 11:31:04 InnoDB: Compressed tables use zlib 1.2.3
130130 11:31:04 InnoDB: Initializing buffer pool, size = 128.0M
130130 11:31:04 InnoDB: Completed initialization of buffer pool
130130 11:31:04 InnoDB: highest supported file format is Barracuda.
130130 11:31:04  InnoDB: Waiting for the background threads to start
130130 11:31:05 InnoDB: 1.1.8 started; log sequence number 1632078
130130 11:31:05 [Note] NDB: NodeID is 21, management server '10.1.1.37:1186'
130130 11:31:06 [Note] NDB[0]: NodeID: 21, all storage nodes connected
130130 11:31:06 [Warning] NDB: server id set to zero - changes logged to bin log with server id zero will be logged with
 another server id by slave mysqlds
130130 11:31:06 [Note] Starting Cluster Binlog Thread
130130 11:31:06 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130130 11:31:06 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
130130 11:31:06 [Note] Server socket created on IP: '0.0.0.0'.
130130 11:31:06 [Note] Event Scheduler: Loaded 0 events
130130 11:31:06 [Note] C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld.exe: ready for connections.
Version: '5.5.25a-ndb-7.3.0-cluster-gpl'  socket: ''  port: 3306  MySQL Cluster Community Server (GPL)
130130 11:31:07 [Note] NDB Binlog: DISCOVER TABLE Event: REPL$mysql/ndb_schema
130130 11:31:07 [Note] NDB Binlog: logging .\mysql\ndb_schema (UPDATED,USE_WRITE)
130130 11:31:07 [Note] NDB Binlog: DISCOVER TABLE Event: REPL$mysql/ndb_apply_status
130130 11:31:07 [Note] NDB Binlog: logging .\mysql\ndb_apply_status (UPDATED,USE_WRITE)
130130 11:31:07 [Note] NDB: Cleaning stray tables from database 'information_schema'
130130 11:31:07 [Note] NDB: Cleaning stray tables from database 'bugmysql'
130130 11:31:07 [Note] NDB: Cleaning stray tables from database 'essai'
130130 11:31:07 [Note] NDB: Cleaning stray tables from database 'ndbinfo'
130130 11:31:07 [Note] NDB: Cleaning stray tables from database 'performance_schema'
130130 11:31:07 [Note] NDB: Cleaning stray tables from database 'sibelcom'
130130 11:31:07 [Note] NDB: Cleaning stray tables from database 'test'
2013-01-30 11:31:07 [NdbApi] INFO     -- Flushing incomplete GCI:s < 290154/2
2013-01-30 11:31:07 [NdbApi] INFO     -- Flushing incomplete GCI:s < 290154/2
130130 11:31:07 [Note] NDB Binlog: starting log at epoch 290154/2
130130 11:31:07 [Note] NDB Binlog: ndb tables writable
130130 11:31:07 [Note] NDB Binlog: Node: 11, subscribe from node 22, Subscriber bitmask 0400000
130130 11:31:07 [Note] NDB Binlog: Node: 12, subscribe from node 22, Subscriber bitmask 0400000
130130 11:31:34 [Note] NDB Binlog: CREATE TABLE Event: REPL$essai/fktest
130130 11:31:58 [Note] NDB Binlog: CREATE TABLE Event: REPL$essai/fktest2
10:32:35 UTC - mysqld got exception 0xc0000005 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=1
max_threads=151
thread_count=1
connection_count=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 338326 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0xc161150
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
13f3fc962    mysqld.exe!get_schema_key_column_usage_record()[sql_show.cc:5507]
13f3f4f53    mysqld.exe!fill_schema_table_by_open()[sql_show.cc:3171]
13f3fa2e0    mysqld.exe!get_all_tables()[sql_show.cc:3838]
13f3fddfb    mysqld.exe!do_fill_table()[sql_show.cc:6884]
13f3fe03f    mysqld.exe!get_schema_tables_result()[sql_show.cc:6984]
13f514dca    mysqld.exe!JOIN::exec()[sql_select.cc:2015]
13f515ffb    mysqld.exe!mysql_select()[sql_select.cc:2697]
13f5163f6    mysqld.exe!handle_select()[sql_select.cc:319]
13f3d3a26    mysqld.exe!execute_sqlcom_select()[sql_parse.cc:4596]
13f3d6493    mysqld.exe!mysql_execute_command()[sql_parse.cc:2150]
13f3d9f1a    mysqld.exe!mysql_parse()[sql_parse.cc:5638]
13f3dacea    mysqld.exe!dispatch_command()[sql_parse.cc:1039]
13f3dbafc    mysqld.exe!do_command()[sql_parse.cc:773]
13f401456    mysqld.exe!do_handle_one_connection()[sql_connect.cc:814]
13f401674    mysqld.exe!handle_one_connection()[sql_connect.cc:735]
13f58b0ee    mysqld.exe!pthread_start()[my_winthread.c:63]
13f822e17    mysqld.exe!_callthreadstartex()[threadex.c:348]
13f822ecb    mysqld.exe!_threadstartex()[threadex.c:326]
7771652d    kernel32.dll!BaseThreadInitThunk()
7794c521    ntdll.dll!RtlUserThreadStart()

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (c142a50): select * from information_schema.key_column_usageConnection ID (thread ID): 2
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
[30 Jan 2013 10:51] Sébastien Barré
To be more precise, the exact version where the bug has been found was 7.3.0 m 1 for windows-64bits, available here: http://dev.mysql.com/downloads/cluster/7.3.html
[31 Jan 2013 6:08] MySQL Verification Team
Thank you for the report.

Verified as described.

Thanks,
Umesh
[23 Feb 2013 11:30] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html
[23 Feb 2013 11:31] Jon Stephens
Documented fix in the NDB 7.3.1 changelog as follows:

        Selecting from the INFORMATION_SCHEMA.KEY_COLUMN_USAGE table while 
        using tables with foreign keys caused mysqld to crash.

Closed.