From: Dmitry Lenev Date: October 27 2010 10:39am Subject: bzr push into mysql-5.5-runtime branch (Dmitry.Lenev:3184 to 3185) List-Archive: http://lists.mysql.com/commits/122070 Message-Id: <20101027103945.3D70A2F0E23@mockturtle> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3185 Dmitry Lenev 2010-10-27 More changes to draft patch refactoring global read lock implementation. Makes GRL yet another type of metadata lock and thus exposes it to deadlock detector in MDL subsystem. Solves bugs #54673 "It takes too long to get readlock for 'FLUSH TABLES WITH READ LOCK'" and #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ LOCK". Work-in-progress. Polished INSERT DELAYED code. modified: sql/sql_insert.cc 3184 Dmitry Lenev 2010-10-27 More changes to draft patch refactoring global read lock implementation. Makes GRL yet another type of metadata lock and thus exposes it to deadlock detector in MDL subsystem. Solves bugs #54673 "It takes too long to get readlock for 'FLUSH TABLES WITH READ LOCK'" and #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ LOCK". Work-in-progress. Polish code related to MDL subsystem killing threads holding conflicting metadata locks. modified: sql/mdl.cc === modified file 'sql/sql_insert.cc' --- a/sql/sql_insert.cc 2010-10-19 13:31:53 +0000 +++ b/sql/sql_insert.cc 2010-10-27 10:39:04 +0000 @@ -77,7 +77,8 @@ #include "sql_audit.h" #ifndef EMBEDDED_LIBRARY -static bool delayed_get_table(THD *thd, TABLE_LIST *table_list); +static bool delayed_get_table(THD *thd, MDL_request *grl_protection_request, + TABLE_LIST *table_list); static int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic, LEX_STRING query, bool ignore, bool log_on); static void end_delayed_insert(THD *thd); @@ -559,7 +560,7 @@ bool open_and_lock_for_insert_delayed(TH DBUG_RETURN(TRUE); bool error= FALSE; - if (delayed_get_table(thd, table_list)) + if (delayed_get_table(thd, &protection_request, table_list)) error= TRUE; else if (table_list->table) { @@ -2072,7 +2073,8 @@ Delayed_insert *find_handler(THD *thd, T */ static -bool delayed_get_table(THD *thd, TABLE_LIST *table_list) +bool delayed_get_table(THD *thd, MDL_request *grl_protection_request, + TABLE_LIST *table_list) { int error; Delayed_insert *di; @@ -2098,8 +2100,6 @@ bool delayed_get_table(THD *thd, TABLE_L */ if (! (di= find_handler(thd, table_list))) { - bool not_used; - if (!(di= new Delayed_insert())) goto end_create; mysql_mutex_lock(&LOCK_thread_count); @@ -2121,8 +2121,7 @@ bool delayed_get_table(THD *thd, TABLE_L /* We need the tickets so that they can be cloned in handle_delayed_insert */ di->grl_protection.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE); - di->grl_protection.ticket= thd->mdl_context.find_ticket( - &di->grl_protection, ¬_used); + di->grl_protection.ticket= grl_protection_request->ticket; init_mdl_requests(&di->table_list); di->table_list.mdl_request.ticket= table_list->mdl_request.ticket; No bundle (reason: useless for push emails).