Bug #47459 Assertion in Diagnostics_area::set_eof_status on OPTIMIZE TABLE
Submitted: 20 Sep 2009 12:12 Modified: 12 May 2010 1:30
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.1,5.4 OS:Any
Assigned to: Jon Olav Hauglid CPU Architecture:Any

[20 Sep 2009 12:12] Philip Stoev
Description:
When executing a concurrent (2 threads) workload that contains CREATE TABLE PARTITION BY, DROP TABLE and ALTER TABLE OPTIMIZE PARTITION, mysqld will assert as follows:

mysqld: sql_class.cc:469: void Diagnostics_area::set_eof_status(THD*): Assertion `! is_set()' failed.

# 15:09:59 #6  0x000000315a42bec9 in __assert_fail () from /lib64/libc.so.6
# 15:09:59 #7  0x000000000062498e in Diagnostics_area::set_eof_status (this=0x7f05807b1bf8, thd=0x7f05807b05c8) at sql_class.cc:469
# 15:09:59 #8  0x000000000055a33f in my_eof (thd=0x7f05807b05c8) at sql_class.h:2321
# 15:09:59 #9  0x00000000007aee49 in mysql_admin_table (thd=0x7f05807b05c8, tables=0x2a35f98, check_opt=0x7f05807b2aa8, operator_name=0xb25825 "optimize",
# 15:09:59     lock_type=TL_WRITE, open_for_modify=false, no_warnings_for_error=false, extra_open_options=0, prepare_func=0,
# 15:09:59     operator_func=0x783c9c <handler::ha_optimize(THD*, st_ha_check_opt*)>, view_operator_func=0) at sql_table.cc:4909
# 15:09:59 #10 0x00000000007af3bc in mysql_optimize_table (thd=0x7f05807b05c8, tables=0x2a35f98, check_opt=0x7f05807b2aa8) at sql_table.cc:4960
# 15:09:59 #11 0x00000000006568a7 in mysql_execute_command (thd=0x7f05807b05c8) at sql_parse.cc:2994
# 15:09:59 #12 0x000000000065d3eb in mysql_parse (thd=0x7f05807b05c8, inBuf=0x2a35ea8 "ALTER TABLE i OPTIMIZE PARTITION p0", length=35, found_semicolon=0x7f0584508ed0)
# 15:09:59     at sql_parse.cc:5931
# 15:09:59 #13 0x000000000065e215 in dispatch_command (command=COM_QUERY, thd=0x7f05807b05c8, packet=0x7f05807c30a9 "", packet_length=35) at sql_parse.cc:1213
# 15:09:59 #14 0x000000000065f5e4 in do_command (thd=0x7f05807b05c8) at sql_parse.cc:854
# 15:09:59 #15 0x000000000064bf15 in handle_one_connection (arg=0x7f05807b05c8) at sql_connect.cc:1127
# 15:09:59 #16 0x000000315b0073da in start_thread () from /lib64/libpthread.so.0
# 15:09:59 #17 0x000000315a4e627d in clone () from /lib64/libc.so.6

How to repeat:
RQG grammar:

query:
        CREATE TABLE _letter ( `int_nokey` INTEGER, `int_key` INTEGER NOT NULL, KEY (`int_key`) ) ENGINE = INNODB { @ranges = sort { $a <=> $b } ($prng->digit(), $prng->fieldType('tinyint_unsigned'), $prng->fieldType('smallint_unsigned')) ; return undef } PARTITION BY RANGE ( `int_nokey` ) ( PARTITION p0 VALUES LESS THAN ( { shift @ranges } ), PARTITION p1 VALUES LESS THAN ( { shift @ranges } ), PARTITION p2 VALUES LESS THAN ( { shift @ranges } ), PARTITION p3 VALUES LESS THAN MAXVALUE ) |
        DROP TABLE IF EXISTS _letter |
        ALTER TABLE _letter OPTIMIZE PARTITION p0;

To execute:

perl runall.pl \
  --basedir=/build/bzr/5.1-bugteam/ \
  --grammar=path/to/grammar \
  --threads=2
[18 Jan 2010 21:27] Mattias Jonsson
This is not a partitioning problem, this is some kind of race in mysql_admin_table and mysql_create_table.

Changed the synopsis from
Assertion in Diagnostics_area::set_eof_status on OPTIMIZE PARTITION
to
Assertion in Diagnostics_area::set_eof_status on OPTIMIZE TABLE

Repeatable with this rqg grammar (I did not get it to crash with MyISAM):
query:
        CREATE TABLE t ( `int_nokey` INTEGER, `int_key` INTEGER NOT NULL, KEY
(`int_key`) ) ENGINE = INNODB |
        DROP TABLE IF EXISTS t |
        OPTIMIZE TABLE t;

De-assigning myself.
[15 Apr 2010 16:54] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/105762

3003 Jon Olav Hauglid	2010-04-15
      Bug #47459 Assertion in Diagnostics_area::set_eof_status on OPTIMIZE TABLE
      
      This assertion could be triggered during execution of OPTIMIZE TABLE for
      InnoDB tables. As part of optimize for InnoDB tables, the table is recreated
      and then opened again. If the reopen failed for any reason, the assertion
      would be triggered. This could for example be caused by a concurrent DROP
      TABLE executed by a different connection. The reason for the assertion was
      that any failures during reopening were ignored.
      
      This patch fixes the problem by making sure that the result of reopening the
      table is checked and that any error messages are sent to the client.
      
      Test case added to innodb_mysql_sync.test.
[19 Apr 2010 6:23] Jon Olav Hauglid
Pushed to mysql-trunk-runtime (Ver 5.5.4-m3).
[27 Apr 2010 9:46] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100427094135-5s49ecp3ckson6e2) (version source revid:alik@sun.com-20100427093843-uekr85qkd7orx12t) (merge vers: 6.0.14-alpha) (pib:16)
[27 Apr 2010 9:48] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100427093804-a2k3rrjpwu5jegu8) (version source revid:alik@sun.com-20100427093804-a2k3rrjpwu5jegu8) (merge vers: 5.5.5-m3) (pib:16)
[27 Apr 2010 9:51] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100427094036-38frbg3famdlvjup) (version source revid:alik@sun.com-20100427093825-92wc8b22d4yg34ju) (pib:16)
[12 May 2010 1:30] Paul DuBois
Note in 5.5.5, 6.0.14 changelogs.

OPTIMIZE TABLE for an InnoDB table could raise an assertion if
another session issued a concurrent DROP TABLE.