1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Fix for bug #16593 "Deadlock or crash in stress test for case where

trigger starts trigger".

In short, the deadlock/crash happened when execution of statement, which used
stored functions or activated triggers, coincided with alteration of the
tables used by these functions or triggers (in highly concurrent environment).

Bug was caused by the incorrect handling of tables from prelocked set in
open_tables() functions in situations when refresh happened. This fix replaces
old smart but not very robust way of handling tables after refresh (which was
closing only old tables), with new one which simply closes all tables opened so
far and restarts open_tables().
Also fixed handling of temporary tables in close_tables_for_reopen().

No test case present since bug manifests itself only in concurrent environment.


sql/mysql_priv.h:
  In order to handle correctly case when table list completely consists from tables
  from prelocked set close_tables_for_reopen() have to accept table list as in/out
  parameter.
sql/sql_base.cc:
  open_tables():
    Removed part of comment  which was out of date.
    Changed handling of case when refresh happens during opening of tables, now
    instead of having code which decides for each table if it should be closed
    we simply close all tables. Old code also incorrectly handled tables from
    prelocked set in this situation which resulted in bug #16593 "Deadlock or
    crash in stress test for case where triggers starting trigger".
  close_tables_for_reopen():
    Now we correctly handle the case when table list completely consists from
    tables from prelocked set. Also now we simply close all tables instead
    leaving temporary tables non-closed (such approach allows easily handle
    correctly tables from prelocked set).
sql/sql_prepare.cc:
  In order to handle correctly case when table list completely consists from tables
  from prelocked set close_tables_for_reopen() have to accept table list as in/out
  parameter.
sql/sql_update.cc:
  In order to handle correctly case when table list completely consists from tables
  from prelocked set close_tables_for_reopen() have to accept table list as in/out
  parameter.
This commit is contained in:
unknown
2006-02-16 16:19:24 +03:00
parent 86733db80b
commit e1c8d9c9b4
4 changed files with 31 additions and 61 deletions

View File

@@ -158,7 +158,7 @@ int mysql_update(THD *thd,
break;
if (!need_reopen)
DBUG_RETURN(1);
close_tables_for_reopen(thd, table_list);
close_tables_for_reopen(thd, &table_list);
}
if (mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
@@ -813,7 +813,7 @@ reopen_tables:
for (TABLE_LIST *tbl= table_list; tbl; tbl= tbl->next_global)
tbl->cleanup_items();
close_tables_for_reopen(thd, table_list);
close_tables_for_reopen(thd, &table_list);
goto reopen_tables;
}