Bug #74085 CREATE TEMPORARY INNODB TABLE crashes server
Submitted: 25 Sep 2014 18:47 Modified: 7 Nov 2014 21:39
Reporter: Filipe Martins Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.6.21 OS:Windows (x64)
Assigned to: CPU Architecture:Any

[25 Sep 2014 18:47] Filipe Martins
Description:
On my SQL Server 5.6.21 64 bits, running on Windows 8, the following SQL below crashes the server with the message "MySQL server has gone away" (error 2006).

Interestingly, if I try restarting the server it fails and prints the following to the log:

2014-09-25 19:42:03 3388 [Note] Plugin 'FEDERATED' is disabled.
2014-09-25 19:42:03 3388 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-09-25 19:42:03 3388 [Note] InnoDB: The InnoDB memory heap is disabled
2014-09-25 19:42:03 3388 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2014-09-25 19:42:03 3388 [Note] InnoDB: Memory barrier is not used
2014-09-25 19:42:03 3388 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-09-25 19:42:03 3388 [Note] InnoDB: Not using CPU crc32 instructions
2014-09-25 19:42:03 3388 [Note] InnoDB: Initializing buffer pool, size = 327.0M
2014-09-25 19:42:03 3388 [Note] InnoDB: Completed initialization of buffer pool
2014-09-25 19:42:03 3388 [Note] InnoDB: Highest supported file format is Barracuda.
2014-09-25 19:42:03 3388 [Note] InnoDB: The log sequence numbers 27179315072 and 27179315072 in ibdata files do not match the log sequence number 27179315102 in the ib_logfiles!
2014-09-25 19:42:03 3388 [Note] InnoDB: Database was not shutdown normally!
2014-09-25 19:42:03 3388 [Note] InnoDB: Starting crash recovery.
2014-09-25 19:42:03 3388 [Note] InnoDB: Reading tablespace information from the .ibd files...
2014-09-25 19:42:03 3388 [Note] InnoDB: Restoring possible half-written data pages 
2014-09-25 19:42:03 3388 [Note] InnoDB: from the doublewrite buffer...
2014-09-25 19:42:05 3388 [Note] InnoDB: 128 rollback segment(s) are active.
2014-09-25 19:42:05 3388 [Note] InnoDB: Waiting for purge to start
2014-09-25 19:42:05 3388 [Note] InnoDB: 5.6.21 started; log sequence number 27179315102
2014-09-25 19:42:05 3388 [Note] Server hostname (bind-address): '*'; port: 3306
2014-09-25 19:42:05 3388 [Note] IPv6 is available.
2014-09-25 19:42:05 3388 [Note]   - '::' resolves to '::';
2014-09-25 19:42:05 3388 [Note] Server socket created on IP: '::'.
2014-09-25 19:42:05 668  InnoDB: Assertion failure in thread 1640 in file dict0dict.cc line 283
InnoDB: Failing assertion: s
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.

But if I restart the machine, SQL Server loads successfully.

How to repeat:
DELIMITER ##

DROP PROCEDURE IF EXISTS teste_break_innodb
CREATE PROCEDURE teste_break_innodb()
	BEGIN

	CREATE TEMPORARY TABLE xxx
		ENGINE=InnoDB
		SELECT 1;

	END

CALL teste_break_innodb
##

Suggested fix:
If I replace "ENGINE=InnoDB" for "ENGINE=MEMORY" OR "ENGINE=MyISAM" it works. This is somehow related with INNODB and temporary tables.
[25 Sep 2014 21:30] MySQL Verification Team
Thank you for the bug report.

Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> USE d
Database changed
mysql> DELIMITER ##
mysql> CREATE PROCEDURE teste_break_innodb()
    -> BEGIN
    -> CREATE TEMPORARY TABLE xxx ENGINE=InnoDB SELECT 1;
    -> END ##
Query OK, 0 rows affected (0.01 sec)

mysql> CALL teste_break_innodb##
Query OK, 1 row affected (0.23 sec)

Your test case:

	END

CALL teste_break_innodb
##
[25 Sep 2014 21:41] MySQL Verification Team
Forgot to paste:

mysql> DROP PROCEDURE IF EXISTS teste_break_innodb##
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE PROCEDURE teste_break_innodb()
    -> BEGIN
    -> CREATE TEMPORARY TABLE xxx ENGINE=InnoDB SELECT 1;
    -> END
    -> CALL teste_break_innodb
    -> ##
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'CALL
teste_break_innodb' at line 5
mysql>
[26 Sep 2014 20:14] Filipe Martins
@Miguel Solorzano 

There's an error in my SQL. It should be:

DELIMITER ##

DROP PROCEDURE IF EXISTS teste_break_innodb;
CREATE PROCEDURE teste_break_innodb()
	BEGIN

	CREATE TEMPORARY TABLE xxx
		ENGINE=InnoDB
		SELECT 1;

	END;
##
CALL teste_break_innodb
[30 Sep 2014 14:05] MySQL Verification Team
Thank you for the feedback. I couldn't repeat. Is your installation an upgrade or fresh one?.

Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.21-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE d;
Query OK, 1 row affected (0.00 sec)

mysql> USE d
Database changed
mysql> DELIMITER ##
mysql>
mysql> DROP PROCEDURE IF EXISTS teste_break_innodb;
    -> CREATE PROCEDURE teste_break_innodb()
    ->  BEGIN
    ->
    ->  CREATE TEMPORARY TABLE xxx
    ->          ENGINE=InnoDB
    ->          SELECT 1;
    ->
    ->  END;
    -> ##
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> CALL teste_break_innodb##
Query OK, 1 row affected (0.17 sec)
[30 Sep 2014 16:38] Filipe Martins
Miguel, and what about if you try just this:

CREATE TEMPORARY TABLE xxx
	ENGINE=InnoDB
	SELECT 1;

I was using an existing installation when I found the problem and upgraded to 5.6.21 to see if it keep occurring. I tried with a new installation and got the same problem.

If you come to wonder about my config, it only has the following idiosyncrasies:

sql-mode="ANSI,STRICT_ALL_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
explicit_defaults_for_timestamp=1
lower_case_table_names=0

I can post the entire file, if needed.
[7 Oct 2014 21:39] MySQL Verification Team
Please provide your my.ini file and have you tried a fresh install?. Still I can't repeat. Thanks.
[8 Nov 2014 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".