Bug #46433 SHOW OPEN TABLES hangs waiting for lock
Submitted: 28 Jul 2009 15:10 Modified: 5 Sep 2009 0:51
Reporter: John Embretsen Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Locking Severity:S2 (Serious)
Version:6.0.12-bzr OS:Linux
Assigned to: Assigned Account CPU Architecture:Any

[28 Jul 2009 15:10] John Embretsen
Description:
SHOW OPEN TABLES command hangs during highly concurrent deadlock-like load, such as the load described in Bug#39193.

Stacktrace from all threads is available here (internal only): 
https://intranet.mysql.com/secure/paste/displaypaste.php?codeid=8491

Stacktrace from the SHOW OPEN TABLES thread:

Thread 2 (Thread 0x7f14a94ae950 (LWP 18924)):
#0  0x00007f14bd47ea94 in __lll_lock_wait () from /lib/libpthread.so.0
#1  0x00007f14bd47a190 in _L_lock_102 () from /lib/libpthread.so.0
#2  0x00007f14bd479a7e in pthread_mutex_lock () from /lib/libpthread.so.0
#3  0x0000000000cbd000 in safe_mutex_lock (mp=0x13974c0, my_flags=0, file=0xe5110d "sql_base.cc", line=740) at thr_mutex.c:225
#4  0x000000000076346f in list_open_tables (thd=0x7f14b40892f8, db=0x0, wild=0x0) at sql_base.cc:740
#5  0x0000000000897918 in fill_open_tables (thd=0x7f14b40892f8, tables=0x3eb79b8, cond=0x0) at sql_show.cc:5757
#6  0x0000000000893273 in get_schema_tables_result (join=0x39b7f10, executed_place=PROCESSED_BY_JOIN_EXEC) at sql_show.cc:6510
#7  0x00000000007ad346 in JOIN::exec (this=0x39b7f10) at sql_select.cc:2398
#8  0x00000000007a9a5b in mysql_select (thd=0x7f14b40892f8, rref_pointer_array=0x7f14b408b2a8, tables=0x3eb79b8, wild_num=0, fields=@0x7f14b408b1c8, 
    conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2684635648, result=0x3eb8508, unit=0x7f14b408ac58, 
    select_lex=0x7f14b408b0c0) at sql_select.cc:3067
#9  0x00000000007af39f in handle_select (thd=0x7f14b40892f8, lex=0x7f14b408abb8, result=0x3eb8508, setup_tables_done_option=0) at sql_select.cc:310
#10 0x000000000070949a in execute_sqlcom_select (thd=0x7f14b40892f8, all_tables=0x3eb79b8) at sql_parse.cc:4964
#11 0x000000000070ad8f in mysql_execute_command (thd=0x7f14b40892f8) at sql_parse.cc:2172
#12 0x0000000000713321 in mysql_parse (thd=0x7f14b40892f8, inBuf=0x3eb74b0 "SHOW OPEN TABLES", length=16, found_semicolon=0x7f14a94adb30)
    at sql_parse.cc:5979
#13 0x0000000000713f1a in dispatch_command (command=COM_QUERY, thd=0x7f14b40892f8, packet=0x7f14b43dfac9 "SHOW OPEN TABLES", packet_length=16)
    at sql_parse.cc:1064
#14 0x00000000007154a1 in do_command (thd=0x7f14b40892f8) at sql_parse.cc:746
#15 0x0000000000702809 in handle_one_connection (arg=0x7f14b40892f8) at sql_connect.cc:1146
#16 0x00007f14bd4783ba in start_thread () from /lib/libpthread.so.0
#17 0x00007f14bc3e4fcd in clone () from /lib/libc.so.6
#18 0x0000000000000000 in ?? ()

Diagnostic commands such as this should continue to work even though the server is "messed up".

How to repeat:
I ran into this while running the Random Query Generator test falcon_deadlock.

Branch & build mysql-6.0-falcon-team tree. Refer to this as FALCON. Version used was: (2759) kevin.lewis@sun.com-20090727153630-g4lz01ad9wpoewn8

Branch the mysql-test-extra-6.0 tree (must be recently up-to-date, since SHOW OPEN TABLES calls were recently added for debugging purposes). Version used was:  (987) pstoev@mysql.com-20090728091820-65q25oz42y0bw8m9

cd mysql-test/gentest/

perl ./runall.pl \
 --basedir=$FALCON \
 --mysqld=--loose-innodb-lock-wait-timeout=5 \
 --mysqld=--table-lock-wait-timeout=5 \
 --mysqld=--loose-falcon-lock-wait-timeout=5 \
 --mysqld=--loose-falcon-debug-mask=2 \
 --mysqld=--skip-safemalloc \
 --grammar=conf/falcon_recovery.yy \
 --gendata=conf/falcon_recovery.zz \
 --mysqld=--falcon-checkpoint-schedule=1 1 1 1 1 \
 --reporters=Deadlock,ErrorLog,Backtrace,Recovery,WinPackage,Shutdown \
 --duration=1200 \
 --vardir=$FALCON/vardirs \
 --mysqld=--log-output=file \
 --queries=100000 \
 --engine=falcon

Can probably be repeated in a simpler way with some effort.

Suggested fix:
Make SHOW OPEN TABLES complete (best-effort) within a reasonable amount time.
[28 Jul 2009 16:57] MySQL Verification Team
Thank you for the bug report. Verified as described.
[30 Jul 2009 12:05] John Embretsen
The calling of the SHOW OPEN TABLES command has now (2009-07-30) been disabled in the Random Query Generator's deadlock handling mechanism. So in order to reproduce this the way it is described above one may need to revert to e.g. the test-extra version mentioned in "How to repeat" or edit the file mysql-test/gentest/lib/GenTest/Deadlock.pm to include the commented out SHOW command.
[5 Sep 2009 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[10 Sep 2018 11:18] Dyre Tjeldvoll
Posted by developer:
 
In feedback state for 9 years. Closing.