Bug #47098 assert in MDL_context::destroy on HANDLER <damaged merge table> OPEN
Submitted: 3 Sep 2009 11:27 Modified: 7 Mar 2010 1:56
Reporter: Matthias Leich Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S3 (Non-critical)
Version:5.4 OS:Any
Assigned to: Lars-Erik Bjørk CPU Architecture:Any
Tags: handler, mdl, merge

[3 Sep 2009 11:27] Matthias Leich
Description:
My script:
----------
--disable_warnings
DROP TABLE IF EXISTS t1,t2,t1_not_exists;
--enable_warnings

CREATE TABLE t1 (f1 int);
CREATE TABLE t2 (f1 int);
CREATE TABLE t3 (f1 int) ENGINE = MERGE UNION (t1,t2);
DROP TABLE t2;
START TRANSACTION;
# Here I get an assertion in MySQL 5.4.
HANDLER t3 OPEN;

# Cleanup
DROP TABLE t1,t3;

Backtrace in mysql-next-bugfixing (5.4):
----------------------------------------
hread 1 (process 26862):
#0  0x00007ff55bf07ce6 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000b57f50 in my_write_core (sig=6) at stacktrace.c:309
#2  0x00000000006efa81 in handle_segfault (sig=6) at mysqld.cc:2738
#3  <signal handler called>
#4  0x00007ff55ae035c5 in raise () from /lib64/libc.so.6
#5  0x00007ff55ae04bb3 in abort () from /lib64/libc.so.6
#6  0x00007ff55adfc1e9 in __assert_fail () from /lib64/libc.so.6
#7  0x0000000000920d77 in MDL_context::destroy (this=0x166e8f8) at mdl.cc:215
#8  0x00000000006d6c2f in ~THD (this=0x166e808) at sql_class.cc:1102
#9  0x00000000006efd3c in unlink_thd (thd=0x166e808) at mysqld.cc:2054
#10 0x00000000006efd7d in one_thread_per_connection_end (thd=0x166e808, put_in_cache=true) at mysqld.cc:2133
#11 0x00000000006f997f in handle_one_connection (arg=0x166e808) at sql_connect.cc:1170
#12 0x00007ff55bf03040 in start_thread () from /lib64/libpthread.so.0
#13 0x00007ff55aea408d in clone () from /lib64/libc.so.6
#14 0x0000000000000000 in ?? ()

In mysql-5.0/5.1-bugteam I get:
-------------------------------
CURRENT_TEST: main.ml2101
mysqltest: At line 11: query 'HANDLER t3 OPEN' failed:
           1168: Unable to open underlying table which
                 is differently defined or of non-MyISAM
                 type or doesn't exist

The result from queries just before the failure was:
DROP TABLE IF EXISTS t1,t2,t1_not_exists;
CREATE TABLE t1 (f1 int);
CREATE TABLE t2 (f1 int);
CREATE TABLE t3 (f1 int) ENGINE = MERGE UNION (t1,t2);
DROP TABLE t2;
START TRANSACTION;

Warnings from just before the error:
Error 1146 Table 'test.t2' doesn't exist
Error 1168 Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist

My environment:
---------------
- mysql-5.0-bugteam late August 2009
- mysql-5.1-bugteam late August 2009
- mysql-6.0-bugteam 2009-09-03
- ./BUILD/compile-pentium64-debug-max
- Linux OpenSuSE 11.0 (64 Bit)
- Intel Core2Duo

How to repeat:
See above
For getting a complete backtrace several attempts
might be required. MTR weakness?, don't know

Suggested fix:
Please correct mysql-next-bugfixing so that the assertion disappears.
Without this
[22 Sep 2009 7:35] 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/84045

2830 lars-erik.bjork@sun.com	2009-09-22
      This is a patch for bug#47098 assert in MDL_context::destroy on
      HANDLER <damaged merge table> OPEN
      
      The assert occurs in MDL_context::destroy when the conenction is
      terminated, because all mdl_tickets have not been released.
      
      MERGE tables does not support being opened using the HANDLER ... OPEN
      command, and trying to do so will result in an error. In the event of
      an error, all tables that are openend, should be closed again. The fix
      for bug#45781 made sure that this also works for MERGE tabeles, which
      causes multiple talbes to be opened.
      
      This fix extends the fix for bug#45781, by ensuring that also all
      locks are released, when MERGE tables are involved.
      modified:
        mysql-test/r/merge.result
        mysql-test/t/merge.test
        sql/sql_handler.cc
[22 Sep 2009 11:23] 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/84103

2831 lars-erik.bjork@sun.com	2009-09-22
      This is a patch for bug#47098 assert in MDL_context::destroy on
      HANDLER <damaged merge table> OPEN.
      
      The assert occurs in MDL_context::destroy when the connection is terminated,
      because all mdl_tickets have not been released.
      MERGE tables do not support being opened using the HANDLER ... OPEN command,
      and trying to do so will result in an error. In the event of an error, all
      tables that are opened, should be closed again. The fix for bug#45781 made
      sure that this also works for MERGE tables, which causes multiple tables to
      be opened.
      This fix extends the fix for bug#45781, by ensuring that also all locks are
      released, when MERGE tables are involved.
      modified:
        mysql-test/r/merge.result
        mysql-test/t/merge.test
        sql/sql_handler.cc
[22 Sep 2009 11:28] Lars-Erik Bjørk
Pushed into mysql-6.0-codebase-bugfixing, 6.0.14-alpha
[30 Sep 2009 8:17] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20090929093622-1mooerbh12e97zux) (version source revid:alik@sun.com-20090923103200-kyo2bakdo6tfb2fb) (merge vers: 6.0.14-alpha) (pib:11)
[1 Oct 2009 17:11] Paul DuBois
Noted in 6.0.14 changelog.

When HANDLER OPEN was attempted on a MERGE table, an error occurred
because this is an unsupported operation, but locks could remain
unreleased. 

Setting report to NDI pending push into 5.4.x.
[9 Dec 2009 13:36] Lars-Erik Bjørk
Pushed to mysql-next-4284 (5.6.0-beta)
[16 Feb 2010 16:46] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100216101445-2ofzkh48aq2e0e8o) (version source revid:kostja@sun.com-20091211154405-c9yhiewr9o5d20rq) (merge vers: 6.0.14-alpha) (pib:16)
[16 Feb 2010 16:55] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100216101208-33qkfwdr0tep3pf2) (version source revid:kostja@sun.com-20091210084103-l4f8u62u4evoy3dc) (pib:16)
[17 Feb 2010 1:10] Paul DuBois
Setting report to Need Merge pending push of Celosia into release tree.
[6 Mar 2010 10:55] 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:56] Paul DuBois
Noted in 5.5.3 changelog.
[13 Apr 2010 5:00] Paul DuBois
Correction: Not present in any 5.5.x release. 5.5.3 changelog entry removed.