Bug #52266 Trying to lock unitialized mutex at storage/myisam/ha_myisam.cc, line 1712
Submitted: 22 Mar 2010 6:18 Modified: 16 Sep 2010 5:43
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S2 (Serious)
Version:mysql-trunk-runtime-exp OS:Any
Assigned to: Konstantin Osipov CPU Architecture:Any

[22 Mar 2010 6:18] Philip Stoev
Description:
When executing a concurrent DDL/MDL/locking workload, mysqld asserted as follows:

safe_mutex: Trying to lock unitialized mutex at /1tb/bzr/mysql-trunk-runtime-exp/storage/myisam/ha_myisam.cc, line 1712

# 13:44:37 #5  0x000000315a434a43 in abort () from /lib64/libc.so.6
# 13:44:37 #6  0x00000000009ded7c in safe_mutex_lock (mp=0x2791a68, try_lock=0 '\0', file=0xba4b18 "/1tb/bzr/mysql-trunk-runtime-exp/storage/myisam/ha_myisam$
# 13:44:37     line=1712) at /1tb/bzr/mysql-trunk-runtime-exp/mysys/thr_mutex.c:106
# 13:44:37 #7  0x0000000000882633 in inline_mysql_mutex_lock (that=0x2791a68, src_file=0xba4b18 "/1tb/bzr/mysql-trunk-runtime-exp/storage/myisam/ha_myisam.cc$
# 13:44:37     src_line=1712) at /1tb/bzr/mysql-trunk-runtime-exp/include/mysql/psi/mysql_thread.h:636
# 13:44:37 #8  0x0000000000882b2f in ha_myisam::info (this=0x368f3e8, flag=26) at /1tb/bzr/mysql-trunk-runtime-exp/storage/myisam/ha_myisam.cc:1712
# 13:44:37 #9  0x00000000008864b9 in ha_myisam::open (this=0x368f3e8, name=0x2791d28 "./mysql/columns_priv", mode=2, test_if_locked=2)
# 13:44:37     at /1tb/bzr/mysql-trunk-runtime-exp/storage/myisam/ha_myisam.cc:730
# 13:44:37 #10 0x000000000070c892 in handler::ha_open (this=0x368f3e8, table_arg=0x368eae8, name=0x2791d28 "./mysql/columns_priv", mode=2, test_if_locked=2)
# 13:44:37     at /1tb/bzr/mysql-trunk-runtime-exp/sql/handler.cc:2093
# 13:44:37 #11 0x00000000006505fe in open_table_from_share (thd=0x34ebf18, share=0x2791988, alias=0xa7d924 "columns_priv", db_stat=39, prgflag=44, ha_open_fl$
# 13:44:37     outparam=0x368eae8, is_create_table=false) at /1tb/bzr/mysql-trunk-runtime-exp/sql/table.cc:1916
# 13:44:37 #12 0x0000000000563b2a in open_table (thd=0x34ebf18, table_list=0x7fcdbd40e5a8, mem_root=0x7fcdbd40d440, ot_ctx=0x7fcdbd40d480, flags=4096)
# 13:44:37     at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_base.cc:2930
# 13:44:37 #13 0x00000000005648fe in open_and_process_table (thd=0x34ebf18, lex=0x34ed788, tables=0x7fcdbd40e5a8, counter=0x7fcdbd40d594, flags=4096,
# 13:44:37     prelocking_strategy=0x7fcdbd40d5d0, has_prelocking_list=false, ot_ctx=0x7fcdbd40d480, new_frm_mem=0x7fcdbd40d440)
# 13:44:37     at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_base.cc:4266
# 13:44:37 #14 0x0000000000565108 in open_tables (thd=0x34ebf18, start=0x7fcdbd40d560, counter=0x7fcdbd40d594, flags=4096, prelocking_strategy=0x7fcdbd40d5d0)
# 13:44:37     at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_base.cc:4666
# 13:44:37 #15 0x0000000000565622 in open_and_lock_tables (thd=0x34ebf18, tables=0x7fcdbd40d690, derived=false, flags=4096, prelocking_strategy=0x7fcdbd40d5d$
# 13:44:37     at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_base.cc:5236
# 13:44:37 #16 0x0000000000554975 in open_and_lock_tables (thd=0x34ebf18, tables=0x7fcdbd40d690, derived=false, flags=4096)
# 13:44:37     at /1tb/bzr/mysql-trunk-runtime-exp/sql/mysql_priv.h:1587
# 13:44:37 #17 0x0000000000542025 in open_grant_tables (thd=0x34ebf18, tables=0x7fcdbd40d690) at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_acl.cc:5230
# 13:44:37 #18 0x000000000054f48b in mysql_create_user (thd=0x34ebf18, list=@0x34ee2c0) at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_acl.cc:5823
# 13:44:37 #19 0x00000000005ae7b4 in mysql_execute_command (thd=0x34ebf18) at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_parse.cc:3849
# 13:44:37 #20 0x00000000005b1a37 in mysql_parse (thd=0x34ebf18, inBuf=0x343cea8 "CREATE USER otto@localhost", length=26, found_semicolon=0x7fcdbd410ee0)
# 13:44:37     at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_parse.cc:5872
# 13:44:37 #21 0x00000000005b2650 in dispatch_command (command=COM_QUERY, thd=0x34ebf18, packet=0x3378f89 " CREATE USER otto@localhost ", packet_length=28)
# 13:44:37     at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_parse.cc:1024
# 13:44:37 #22 0x00000000005b3ae6 in do_command (thd=0x34ebf18) at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_parse.cc:710
# 13:44:37 #23 0x000000000067e1e8 in do_handle_one_connection (thd_arg=0x34ebf18) at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_connect.cc:1174
# 13:44:37 #24 0x000000000067e2b7 in handle_one_connection (arg=0x34ebf18) at /1tb/bzr/mysql-trunk-runtime-exp/sql/sql_connect.cc:1113
# 13:44:37 #25 0x000000315b0073da in start_thread () from /lib64/libpthread.so.0
# 13:44:37 #26 0x000000315a4e627d in clone () from /lib64/libc.so.6

How to repeat:
If this is repeatable, a simplified test case will be uploaded. In the meantime, the bug will be set to Verified with the expectation that it can be fixed based on the stack trace alone.
[22 Mar 2010 6:28] Philip Stoev
Core and binary:

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

Source:

revision-id: kostja@sun.com-20100319105459-qa2716enp8v22cj1
date: 2010-03-19 13:54:59 +0300
build-date: 2010-03-22 08:20:37 +0200
revno: 2999
branch-nick: mysql-trunk-runtime-exp
[22 Mar 2010 8:24] 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/103930

3000 Konstantin Osipov	2010-03-22
      An attempt to fix Bug#52266 "Trying to lock unitialized mutex at 
      storage/myisam/ha_myisam.cc": when we call open_table_from_share()
      there is almost no reference to the share except the one 
      on MDL_lock, and this can go away quickly if someone
      releases a lock/table in a concurrent connection. Make sure we
      conservatively reference the share so that it doesn't
      disappear while we add a new table to its list of used
      tables.
[22 Mar 2010 8:28] 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/103932

3000 Konstantin Osipov	2010-03-22
      An attempt to fix Bug#52266 "Trying to lock unitialized mutex at 
      storage/myisam/ha_myisam.cc": when we call open_table_from_share()
      there is almost no reference to the share except the one 
      on MDL_lock, and this can go away quickly if someone
      releases a lock/table in a concurrent connection. Make sure we
      conservatively reference the share so that it doesn't
      disappear while we add a new table to its list of used
      tables.
[29 Mar 2010 16:02] Philip Stoev
The patch provided by Kostja appears to fix this issue.
[16 Sep 2010 5:43] Konstantin Osipov
The bug is not in any released version, the project this bug was found in is complete.