Bug #54105 assert in MDL_context::release_locks_stored_before
Submitted: 31 May 2010 14:54 Modified: 22 Sep 2010 20:37
Reporter: Matthias Leich Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S3 (Non-critical)
Version:5.5+ OS:Any
Assigned to: Jon Olav Hauglid CPU Architecture:Any
Tags: mdl

[31 May 2010 14:54] Matthias Leich
Description:
The assert happens in sql/mdl.cc line 2067:
  /*
    If all locks were released, then the sentinel was not present
    in the list. It must never happen because the sentinel was
    bogus, i.e. pointed to a ticket that no longer exists.
  */
  DBUG_ASSERT(! m_tickets.is_empty() || sentinel == NULL); 

  DBUG_VOID_RETURN;

RQG test with
- 64 threads
- derivate of the WL5005_* grammars

Result on 5.6.99-m4-debug
mysql-next-mr revno: 3153 2010-05-31
------------------------------------
#0  0x00007f712f537ce6 in pthread_kill ()
                       from /lib64/libpthread.so.0
#1  0x00000000009fb6a1 in my_write_core (sig=6)
                       at .../mysys/stacktrace.c:326
#2  0x000000000053cbf6 in handle_segfault (sig=6)
                       at .../sql/mysqld.cc:2787
#3  <signal handler called>
#4  0x00007f712e74f5c5 in raise ()
                       from /lib64/libc.so.6
#5  0x00007f712e750bb3 in abort ()
                       from /lib64/libc.so.6
#6  0x00007f712e7481e9 in __assert_fail () from /lib64/libc.so.6
#7  0x00000000006aa71c in MDL_context::release_locks_stored_before (this=0x7f7118068d58, sentinel=0x7f711806c550)
                       at .../sql/mdl.cc:2067
#8  0x00000000006aa7c4 in MDL_context::rollback_to_savepoint (this=0x7f7118068d58, mdl_savepoint=0x7f711806c550)
                       at .../sql/mdl.cc:2258
#9  0x00000000005834f0 in close_tables_for_reopen (thd=0x7f7118068c88, tables=0x46c68e50, start_of_statement_svp=0x7f711806c550)
                       at .../sql/sql_base.cc:5528
#10 0x0000000000586e34 in open_tables (thd=0x7f7118068c88, start=0x46c68e50, counter=0x46c68e84, flags=0, prelocking_strategy=0x46c68ec0)
                       at .../sql/sql_base.cc:4673
#11 0x00000000005872f8 in open_and_lock_tables (thd=0x7f7118068c88, tables=0x1d7e050, derived=false, flags=0, prelocking_strategy=0x46c68ec0)
                       at .../sql/sql_base.cc:5221
#12 0x00000000005767f3 in open_and_lock_tables (thd=0x7f7118068c88, tables=0x1d7e050, derived=false, flags=0)
                       at .../sql/sql_base.h:356
#13 0x00000000005875f9 in open_n_lock_single_table (thd=0x7f7118068c88, table_l=0x1d7e050, lock_type=TL_READ, flags=0)
                       at .../sql/sql_base.cc:5082
#14 0x000000000063f4e6 in mysql_checksum_table (thd=0x7f7118068c88, tables=0x1d7daf0, check_opt=0x7f711806b278)
                       at .../sql/sql_table.cc:7977
#15 0x00000000005cde70 in mysql_execute_command (thd=0x7f7118068c88)
                       at .../sql/sql_parse.cc:2985
#16 0x00000000005d385e in mysql_parse (thd=0x7f7118068c88, inBuf=0x1d7d9a8 "CHECKSUM TABLE testdb_S . t1_view2_S  , testdb_S . t1_base2_S", length=61, parser_state=0x46c6a9b0)
                       at .../sql/sql_parse.cc:5816
#17 0x00000000005d445d in dispatch_command (command=COM_QUERY, thd=0x7f7118068c88, packet=0x7f7118094029 "", packet_length=63)
                       at .../sql/sql_parse.cc:1085
#18 0x00000000005d5985 in do_command (thd=0x7f7118068c88)
                       at .../sql/sql_parse.cc:771
#19 0x00000000006a0df0 in do_handle_one_connection (thd_arg=0x7f7118068c88)
                       at .../sql/sql_connect.cc:1195
#20 0x00000000006a0eb5 in handle_one_connection (arg=0x7f7118068c88)
                       at .../sql/sql_connect.cc:1134
#21 0x00007f712f533040 in start_thread ()
                       from /lib64/libpthread.so.0
#22 0x00007f712e7f008d in clone ()
                       from /lib64/libc.so.6
#23 0x0000000000000000 in ?? ()

How to repeat:
I will try to come up with simplified grammars soon.
[2 Jun 2010 9:48] Matthias Leich
Archive with grammars and protocol of RQG run

Attachment: 54105.tgz (application/x-compressed-tar, text), 74.89 KiB.

[10 Aug 2010 13:48] Jon Olav Hauglid
Repeatable in mysql-5.5-runtime-stage using RQG.
[10 Aug 2010 19:45] Konstantin Osipov
I may have an idea for a solution based on the backtrace alone, let's discuss on IRC.
[12 Aug 2010 15:47] 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/115616

3101 Jon Olav Hauglid	2010-08-12
      Bug #54105 assert in MDL_context::release_locks_stored_before
      
      The problem was that SHOW CREATE EVENT released all metadata locks
      held by the current transaction. This made any exisiting savepoints
      invalid, triggering the assert when ROLLBACK TO SAVEPOINT later
      was executed.
      
      This patch fixes the problem by making sure SHOW CREATE EVENT only
      releases metadata locks acquired by the statement itself.
      
      Test case added to event_trans.test.
[13 Aug 2010 8:03] 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/115641

3104 Jon Olav Hauglid	2010-08-13
      Bug #54105 assert in MDL_context::release_locks_stored_before
      
      The problem was that SHOW CREATE EVENT released all metadata locks
      held by the current transaction. This made any exisiting savepoints
      invalid, triggering the assert when ROLLBACK TO SAVEPOINT later
      was executed.
      
      This patch fixes the problem by making sure SHOW CREATE EVENT only
      releases metadata locks acquired by the statement itself.
      
      Test case added to event_trans.test.
[13 Aug 2010 8:04] Jon Olav Hauglid
Pushed to mysql-5.5-runtime (5.5.6).
[25 Aug 2010 9:23] Bugs System
Pushed into mysql-5.5 5.5.6-m3 (revid:alik@ibmvm-20100825092002-2yvkb3iwu43ycpnm) (version source revid:alik@ibmvm-20100825092002-2yvkb3iwu43ycpnm) (merge vers: 5.5.6-m3) (pib:20)
[30 Aug 2010 8:31] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@sun.com-20100830082732-n2eyijnv86exc5ci) (version source revid:alik@sun.com-20100830082732-n2eyijnv86exc5ci) (merge vers: 5.6.1-m4) (pib:21)
[30 Aug 2010 8:35] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100830082745-n6sh01wlwh3itasv) (version source revid:alik@sun.com-20100830082745-n6sh01wlwh3itasv) (pib:21)
[22 Sep 2010 20:37] Paul DuBois
Noted in 5.5.6, 5.6.1 changelogs.

SHOW CREATE EVENT released all metadata locks held by the current
transaction. This invalidated any existing savepoints and raised an
assertion if ROLLBACK TO SAVEPOINT was executed.