Bug #50406 Deadlock around system variables and the fill_status() function
Submitted: 18 Jan 2010 10:26 Modified: 3 Mar 2010 13:57
Reporter: Philip Stoev Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Locking Severity:S1 (Critical)
Version:next-mr, 6.0-codebase-bugfixing OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: pushbuild, rqg_pb2, test failure

[18 Jan 2010 10:26] Philip Stoev
Description:
When executing an MDL-targeted concurrent workload with DDL in PB2, mysqld deadlocked rock solid with many of the threads in the following backtrace:

#6  0x0840fc2b in fill_status (thd=0xa9a75028, tables=0xb2aded0, cond=0x0) at sql_show.cc:6114
#7  0x0840309b in get_schema_tables_result (join=0xa9a9e7a0, executed_place=PROCESSED_BY_JOIN_EXEC) at sql_show.cc:6794
#8  0x08327a91 in JOIN::exec (this=0xa9a9e7a0) at sql_select.cc:2456
#9  0x0832404f in mysql_select (thd=0xa9a75028, rref_pointer_array=0xa9a76578, tables=0xb2aded0, wild_num=0, fields=@0xa9a76508, conds=0x0, og_num=0,

    order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2685668096, result=0xb2ae578, unit=0xa9a75fac, select_lex=0xa9a76474)
    at sql_select.cc:3137
#10 0x0832991c in handle_select (thd=0xa9a75028, lex=0xa9a75f50, result=0xb2ae578, setup_tables_done_option=0) at sql_select.cc:304

#11 0x082826a2 in execute_sqlcom_select (thd=0xa9a75028, all_tables=0xb2aded0) at sql_parse.cc:4940

#12 0x08283467 in mysql_execute_command (thd=0xa9a75028) at sql_parse.cc:2113
#13 0x0828bcf1 in mysql_parse (thd=0xa9a75028, inBuf=0xb2adcd8 "SHOW STATUS", length=11, found_semicolon=0xa98d8e58) at sql_parse.cc:5971

#14 0x0828d026 in dispatch_command (command=COM_QUERY, thd=0xa9a75028, packet=0xa9aa86b1 "SHOW STATUS", packet_length=11) at sql_parse.cc:1090
#15 0x0828e28e in do_command (thd=0xa9a75028) at sql_parse.cc:774
#16 0x0827c08c in do_handle_one_connection (thd_arg=0xa9a75028) at sql_connect.cc:1173

#17 0x0827c13d in handle_one_connection (arg=0xa9a75028) at sql_connect.cc:1113
#18 0x0089a45b in start_thread () from /lib/libpthread.so.0
#19 0x007f1c4e in clone () from /lib/libc.so.6

How to repeat:
The backtraces for the rest of the threads will be uploaded shortly.
[18 Jan 2010 10:28] Philip Stoev
thread stacks for 50406 except background innodb threads

Attachment: bug50406.threads.txt (text/plain), 23.78 KiB.

[3 Mar 2010 13:24] Jon Olav Hauglid
This is a deadlock between
1) SET GLOBAL EVENT_SCHEDULER= ON
     Which holds LOCK_event_metadata (guard PolyLock for EVENT_SCHEDULER)
     and tries to lock LOCK_global_system_variables during THD:init()
2) SET GLOBAL EVENT_SCHEDULER= OFF
     Which holds LOCK_global_system_variables
     and tries to lock LOCK_event_metadata, both during event_scheduler_update()

Non-determinstic MTR test case:

connect(con2, localhost, root);

let $try = 1000;

while ($try)
{
        connection con2;
        --send SET GLOBAL EVENT_SCHEDULER= ON;

        connection default;
        SET GLOBAL EVENT_SCHEDULER= OFF;

        connection con2;
        --reap

        dec $try;
}
[3 Mar 2010 13:57] Jon Olav Hauglid
Closing this bug as a duplicate of bug#51160