Bug #50912 Assertion `ticket->m_type >= mdl_request->type' failed on HANDLER + I_S

Submitted: 4 Feb 2010 12:33 Modified: 7 Mar 2010 1:02
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S2 (Serious)
Version:mysql-next-4284 OS:Any
Assigned to: Jon Olav Hauglid CPU Architecture:Any

[4 Feb 2010 12:33] Philip Stoev
Description:
Using I_S tables after HANDLER causes the following assertion:

mysqld: mdl.cc:1286: bool MDL_context::try_acquire_lock(MDL_request*): Assertion `ticket->m_type >= mdl_request->type' failed.

#6  0x000000315a42bec9 in __assert_fail () from /lib64/libc.so.6
#7  0x00000000008464ff in MDL_context::try_acquire_lock (this=0x2d27ce8, mdl_request=0x2e21c68) at mdl.cc:1286
#8  0x00000000006944e4 in open_table_get_mdl_lock (thd=0x2d27c18, table_list=0x2e21938, mdl_request=0x2e21c68, ot_ctx=0x7f82ea03c160, flags=514)
    at sql_base.cc:2390
#9  0x00000000006995bb in open_table (thd=0x2d27c18, table_list=0x2e21938, mem_root=0x7f82ea03c120, ot_ctx=0x7f82ea03c160, flags=514) at sql_base.cc:2664
#10 0x000000000069a835 in open_and_process_table (thd=0x2d27c18, lex=0x2d294b0, tables=0x2e21938, counter=0x7f82ea03c2ac, flags=514,
    prelocking_strategy=0x7f82ea03c230, has_prelocking_list=false, ot_ctx=0x7f82ea03c160, new_frm_mem=0x7f82ea03c120) at sql_base.cc:4176
#11 0x000000000069af6d in open_tables (thd=0x2d27c18, start=0x7f82ea03c270, counter=0x7f82ea03c2ac, flags=514, prelocking_strategy=0x7f82ea03c230)
    at sql_base.cc:4497
#12 0x000000000054af08 in open_tables (thd=0x2d27c18, tables=0x7f82ea03c270, counter=0x7f82ea03c2ac, flags=514) at mysql_priv.h:1538
#13 0x000000000069b3c0 in open_normal_and_derived_tables (thd=0x2d27c18, tables=0x2e21938, flags=514) at sql_base.cc:5150
#14 0x00000000007c5a8f in get_all_tables (thd=0x2d27c18, tables=0x2d83a98, cond=0x0) at sql_show.cc:3471
#15 0x00000000007b241a in get_schema_tables_result (join=0x2d8f0d8, executed_place=PROCESSED_BY_JOIN_EXEC) at sql_show.cc:6316
#16 0x00000000006d6c18 in JOIN::exec (this=0x2d8f0d8) at sql_select.cc:1801
#17 0x00000000006d3833 in mysql_select (thd=0x2d27c18, rref_pointer_array=0x2d29d00, tables=0x2d83a98, wild_num=1, fields=@0x2d29c38, conds=0x0, og_num=0,
    order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2684619264, result=0x2d85758, unit=0x2d29550, select_lex=0x2d29b30)
    at sql_select.cc:2473
#18 0x00000000006d8ceb in handle_select (thd=0x2d27c18, lex=0x2d294b0, result=0x2d85758, setup_tables_done_option=0) at sql_select.cc:272
#19 0x0000000000645d43 in execute_sqlcom_select (thd=0x2d27c18, all_tables=0x2d83a98) at sql_parse.cc:4571
#20 0x00000000006472a8 in mysql_execute_command (thd=0x2d27c18) at sql_parse.cc:2043
#21 0x000000000064ebc0 in mysql_parse (thd=0x2d27c18, inBuf=0x2d83888 "SELECT * FROM information_schema . tables", length=41, found_semicolon=0x7f82ea03ef10)
    at sql_parse.cc:5584
#22 0x000000000064f7d9 in dispatch_command (command=COM_QUERY, thd=0x2d27c18, packet=0x2d7b7f9 "SELECT * FROM information_schema . tables ",
    packet_length=42) at sql_parse.cc:1008
#23 0x0000000000650c3c in do_command (thd=0x2d27c18) at sql_parse.cc:694
#24 0x000000000063f354 in handle_one_connection (arg=0x2d27c18) at sql_connect.cc:1163
#25 0x000000315b0073da in start_thread () from /lib64/libpthread.so.0
#26 0x000000315a4e627d in clone () from /lib64/libc.so.6

How to repeat:
CREATE TABLE IF NOT EXISTS t1 (f1 integer);
HANDLER t1  OPEN AS A;
SELECT * FROM information_schema . tables ;
[5 Feb 2010 14:17] Jon Olav Hauglid
HANDLER OPEN acquires a metadata lock of type MDL_SHARED.
The I_S query requests a MDL_SHARED_HIGH_PRIO lock.
The existing MDL_SHARED ticket is found in find_ticket() since
it satisfies ticket->has_stronger_or_equal_type(mdl_request->type).

However since MDL_SHARED_HIGH_PRIO < MDL_SHARED, this assert is
triggered right after. A similar assert would have been triggered
in clone_ticket() right afterwards.
[5 Feb 2010 16:00] 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/99478

3077 Jon Olav Hauglid	2010-02-05
      Bug #50912 Assertion `ticket->m_type >= mdl_request->type'
                 failed on HANDLER + I_S
      
      This assert was triggered when an I_S query tried to lock a table
      already locked by a HANDLER statement in the same connection. 
      
      First the HANDLER took a MDL_SHARED lock. Afterwards, the I_S query
      requested a MDL_SHARED_HIGH_PRIO lock. The existing MDL_SHARED ticket
      is found in find_ticket() since it satisfies 
      ticket->has_stronger_or_equal_type(mdl_request->type) as MDL_SHARED
      and MDL_SHARED_HIGH_PRIO have equal strengths, just different priority.
      
      However, two asserts later check lock type strengths using relational
      operators (>= and <=) rather than MDL_ticket::has_stronger_or_equal_type().
      These asserts are triggered since MDL_SHARED >= MDL_SHARED_HIGH_PRIORITY
      is false (mapped to 1 and 2 respectively).
      
      This patch updates the asserts to use MDL_ticket::has_stronger_or_equal_type()
      rather than relational operators to check lock type strength.
      
      Test case added to include/handler.inc.
[5 Feb 2010 20:20] Dmitry Lenev
Approved with minor comments sent by e-mail.
[6 Feb 2010 9:44] 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/99538

3084 Jon Olav Hauglid	2010-02-06
      Bug #50912 Assertion `ticket->m_type >= mdl_request->type'
                 failed on HANDLER + I_S
      
      This assert was triggered when an I_S query tried to acquire a
      metadata lock on a table which was already locked by a HANDLER
      statement in the same connection.
      
      First the HANDLER took a MDL_SHARED lock. Afterwards, the I_S query
      requested a MDL_SHARED_HIGH_PRIO lock. The existing MDL_SHARED ticket
      is found in find_ticket() since it satisfies 
      ticket->has_stronger_or_equal_type(mdl_request->type) as MDL_SHARED
      and MDL_SHARED_HIGH_PRIO have equal strengths, just different priority.
      
      However, two asserts later check lock type strengths using relational
      operators (>= and <=) rather than MDL_ticket::has_stronger_or_equal_type().
      These asserts are triggered since MDL_SHARED >= MDL_SHARED_HIGH_PRIORITY
      is false (mapped to 1 and 2 respectively).
      
      This patch updates the asserts to use MDL_ticket::has_stronger_or_equal_type()
      rather than relational operators to check lock type strength.
      
      Test case added to include/handler.inc.
[6 Feb 2010 9:46] Jon Olav Hauglid
Pushed to mysql-next-4284.

Closing the bug as the patch adjusts two asserts that only exist in 
next-4284. Since this is an internal tree, no documentation changes
are necessary.
[16 Feb 2010 16:49] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100216101445-2ofzkh48aq2e0e8o) (version source revid:kostja@sun.com-20100210211106-nq8ztcq2z9o4csit) (merge vers: 6.0.14-alpha) (pib:16)
[16 Feb 2010 16:59] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100216101208-33qkfwdr0tep3pf2) (version source revid:kostja@sun.com-20100206103007-2te50xtpwd7o3spx) (pib:16)
[6 Mar 2010 11:03] 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:02] Paul DuBois
No changelog entry needed.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.061 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.