1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Backport of:

------------------------------------------------------------
revno: 2617.69.37
committer: Dmitry Lenev <dlenev@mysql.com>
branch nick: mysql-next-bg46748
timestamp: Fri 2009-08-21 18:17:02 +0400
message:
  Fix for bug #46748 "Assertion in MDL_context::wait_for_locks()
  on INSERT + CREATE TRIGGER".

  Concurrent execution of statements involving stored functions or triggers
  which were using several tables and DDL statements which affected those
  tables on debug build of server might have led to assertion failures in
  MDL_context::wait_for_locks(). Non-debug build was not affected.

  The problem was that during back-off which happens when open_tables()
  encounters conflicting metadata lock for one of the tables being open
  we didn't reset MDL_request::ticket value for requests which correspond
  to tables from extended prelocking set. Since these requests are part
  of of list of requests to be waited for in Open_table_context this broke
  assumption that ticket value for them is 0 in MDL_context::wait_for_locks()
  and caused assertion failure.

  This fix ensures that close_tables_for_reopen(), which performs this back-off
  resets MDL_request::ticket value not only for tables directly used by the
  statement but also for tables from extended prelocking set, thus satisfying
  assumption described above.



mysql-test/r/mdl_sync.result:
  Added test case for bug #46748 "Assertion in MDL_context::wait_for_locks()
  on INSERT + CREATE TRIGGER".
mysql-test/t/mdl_sync.test:
  Added test case for bug #46748 "Assertion in MDL_context::wait_for_locks()
  on INSERT + CREATE TRIGGER".
sql/sql_base.cc:
  Since metadata lock requests for tables from extended part of prelocking
  set are also part of list of requests to be waited for in Open_table_context
  in close_tables_for_reopen() we have to reset MDL_request::ticket 
  values for them to assumptions in MDL_context::wait_for_locks().
This commit is contained in:
Konstantin Osipov
2009-12-09 12:44:05 +03:00
parent 59f82702a1
commit 736db89a76
3 changed files with 134 additions and 2 deletions

View File

@ -5104,19 +5104,31 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count,
void close_tables_for_reopen(THD *thd, TABLE_LIST **tables)
{
TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
TABLE_LIST *tmp;
/*
If table list consists only from tables from prelocking set, table list
for new attempt should be empty, so we have to update list's root pointer.
*/
if (thd->lex->first_not_own_table() == *tables)
if (first_not_own_table == *tables)
*tables= 0;
thd->lex->chop_off_not_own_tables();
sp_remove_not_own_routines(thd->lex);
for (TABLE_LIST *tmp= *tables; tmp; tmp= tmp->next_global)
for (tmp= *tables; tmp; tmp= tmp->next_global)
{
tmp->table= 0;
tmp->mdl_request.ticket= NULL;
}
/*
Metadata lock requests for tables from extended part of prelocking set
are part of list of requests to be waited for in Open_table_context.
So to satisfy assumptions in MDL_context::wait_for_locks(), which will
performs the waiting, we have to reset MDL_request::ticket values for
them as well.
*/
for (tmp= first_not_own_table; tmp; tmp= tmp->next_global)
tmp->mdl_request.ticket= NULL;
close_thread_tables(thd);
if (!thd->locked_tables_mode)
thd->mdl_context.release_all_locks();