Bug #50907 Assertion `hash_tables->table->next == __null' on HANDLER OPEN

Submitted: 4 Feb 2010 10:35 Modified: 7 Mar 2010 1:02
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S2 (Serious)
Version:mysql-next-4284 OS:Any
Assigned to: Jon Olav Hauglid CPU Architecture:Any

[4 Feb 2010 10:35] Philip Stoev
Description:
When executing the usual RQG MDL DDL workload, but with no transactions and autocommit=on, mysqld asserted as follows:

mysqld: sql_handler.cc:326: bool mysql_ha_open(THD*, TABLE_LIST*, bool): Assertion `hash_tables->table->next == __null' failed.

#6  0x000000315a42bec9 in __assert_fail () from /lib64/libc.so.6
#7  0x0000000000548a1b in mysql_ha_open (thd=0x1fccec8, tables=0x2019a78, reopen=false) at sql_handler.cc:326
#8  0x000000000064c773 in mysql_execute_command (thd=0x1fccec8) at sql_parse.cc:3818
#9  0x000000000064ebc0 in mysql_parse (thd=0x1fccec8, inBuf=0x2019968 "HANDLER testdb_N . t1_temp2_N  OPEN", length=35, found_semicolon=0x7fde3d818f10)
    at sql_parse.cc:5584
#10 0x000000000064f7d9 in dispatch_command (command=COM_QUERY, thd=0x1fccec8, packet=0x1fb10c9 "HANDLER testdb_N . t1_temp2_N  OPEN ", packet_length=36)
    at sql_parse.cc:1008
#11 0x0000000000650c3c in do_command (thd=0x1fccec8) at sql_parse.cc:694
#12 0x000000000063f354 in handle_one_connection (arg=0x1fccec8) at sql_connect.cc:1163
#13 0x000000315b0073da in start_thread () from /lib64/libpthread.so.0
#14 0x000000315a4e627d in clone () from /lib64/libc.so.6

(gdb) frame 7
#7  0x0000000000548a1b in mysql_ha_open (thd=0x1fccec8, tables=0x2019a78, reopen=false) at sql_handler.cc:326
326       DBUG_ASSERT(hash_tables->table->next == NULL);

(gdb) print hash_tables->table->next
$1 = (TABLE *) 0x7fde3813e858

This particular workload has never been used before, so I can not tell if this is a regression or not.

How to repeat:
If this is repeatable, a test case will be provided. In the meantime, the core and the binary will be uploaded.
[4 Feb 2010 10:41] Philip Stoev
Core and binary:

http://mysql-systemqa.s3.amazonaws.com/var-bug50907.zip

Source:

revision-id: dlenev@mysql.com-20100204062532-ptky4sdbl040e583
date: 2010-02-04 09:25:32 +0300
build-date: 2010-02-04 12:35:43 +0200
revno: 3072
branch-nick: mysql-next-4284
[4 Feb 2010 11:07] Philip Stoev
not reproducible on mysql-next-mr
[4 Feb 2010 11:34] Philip Stoev
Non-concurrent simplified test case:

--disable_abort_on_error
CREATE TABLE `table0_int_autoinc` ( f1 integer );
CREATE TABLE `table1_int_autoinc` ( f1 integer );
CREATE TEMPORARY TABLE IF NOT EXISTS t1_temp1_N  LIKE test.table1_int_autoinc;
CREATE TEMPORARY TABLE IF NOT EXISTS testdb_S . t1_temp1_N  LIKE test.table0_int_autoinc;
HANDLER testdb_S . t1_temp1_N  OPEN;

Note that Mysqld seems to allow you to create a temporary table in a database that does not exist.

next-mr is not affected.
[4 Feb 2010 16:39] Jon Olav Hauglid
Even simpler test case:
CREATE TEMPORARY TABLE t1 (id int);
CREATE TEMPORARY TABLE t2 (id int);
HANDLER t2 OPEN;

Not present in next-mr simply because the assert is not there.

The reason the assert is triggered is that temporary tables 
for one connection are linked together using table->next
So if you have two temporary tables and then try to
open a HANDLER on the last one (which has ->next set to point
to the first), the assert is triggered.
[5 Feb 2010 12:36] 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/99408

3076 Jon Olav Hauglid	2010-02-05
      Bug #50907 Assertion `hash_tables->table->next == __null' on 
                 HANDLER OPEN
      
      The problem was a too restrictive assert in the code for 
      HANDLER ... OPEN and HANDLER ... READ that checked table->next
      to verify that we didn't open views or merge tables.
      
      This pointer is also used to link temporary tables together
      (see thd->temporary_tables). In this case table->next can be
      set even if we're trying to open a single table.
      
      This patch adjust the two asserts to also check for the presence
      of temporary tables.
      
      Test case added to handler_myisam.test.
[5 Feb 2010 14:52] 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/99433

3076 Jon Olav Hauglid	2010-02-05
      Bug #50907 Assertion `hash_tables->table->next == __null' on 
                 HANDLER OPEN
      
      The problem was a too restrictive assert in the code for 
      HANDLER ... OPEN and HANDLER ... READ that checked table->next
      to verify that we didn't open views or merge tables.
      
      This pointer is also used to link temporary tables together
      (see thd->temporary_tables). In this case TABLE::next can be
      set even if we're trying to open a single table.
      
      This patch adjust the two asserts to also check for the presence
      of temporary tables.
      
      Test case added to handler_myisam.test.
[5 Feb 2010 15:40] Jon Olav Hauglid
Pushed to mysql-next-4284.

Setting the bug to closed since the assert was only present in next-4284
and this is an internal tree. No documentation changes needed.

Note that the above commit message by mistake refers to 
handler_myisam.test. It should be include/handler.inc.
[16 Feb 2010 16:47] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100216101445-2ofzkh48aq2e0e8o) (version source revid:kostja@sun.com-20100210211106-nq8ztcq2z9o4csit) (merge vers: 6.0.14-alpha) (pib:16)
[16 Feb 2010 16:56] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100216101208-33qkfwdr0tep3pf2) (version source revid:kostja@sun.com-20100205174100-d6kq4y5ujt6jcopc) (pib:16)
[6 Mar 2010 11:02] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@mysql.com-20100216221947-luyhph0txl2c5tc8) (merge vers: 5.5.99-m3) (pib:16)
[7 Mar 2010 1:02] Paul DuBois
No changelog entry needed.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.077 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.