summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authordlenev@mysql.com <>2005-10-17 22:37:24 +0400
committerdlenev@mysql.com <>2005-10-17 22:37:24 +0400
commitea0b89aeae83480ff68483e03a61aec3f50eebdf (patch)
tree6ab27efff544719f937826ca792589038dab8878 /sql/sql_table.cc
parentdad1e2048d3ac1477557a2645ccd323143601723 (diff)
downloadmariadb-git-ea0b89aeae83480ff68483e03a61aec3f50eebdf.tar.gz
Fix for bug #12739 "Deadlock in multithreaded environment during creating/
droping trigger on InnoDB table". Deadlock occured in cases when we were trying to create two triggers for the same InnoDB table concurrently and both threads were able to reach close_cached_table() simultaneously. Bugfix implements new approach to table locking and table cache invalidation during creation/dropping of trigger. No testcase is supplied since bug was repeatable only under high concurrency.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 0bc1537235b..1dc952ab2e9 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1950,8 +1950,8 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table,
{
char* backup_dir= thd->lex->backup_dir;
char src_path[FN_REFLEN], dst_path[FN_REFLEN];
- char* table_name = table->table_name;
- char* db = thd->db ? thd->db : table->db;
+ char* table_name= table->table_name;
+ char* db= table->db;
if (fn_format_relative_to_data_home(src_path, table_name, backup_dir,
reg_ext))
@@ -1987,12 +1987,15 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table,
Now we should be able to open the partially restored table
to finish the restore in the handler later on
*/
- if (!(table->table = reopen_name_locked_table(thd, table)))
+ pthread_mutex_lock(&LOCK_open);
+ if (reopen_name_locked_table(thd, table))
{
- pthread_mutex_lock(&LOCK_open);
unlock_table_name(thd, table);
pthread_mutex_unlock(&LOCK_open);
+ DBUG_RETURN(send_check_errmsg(thd, table, "restore",
+ "Failed to open partially restored table"));
}
+ pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(0);
}
@@ -2089,12 +2092,16 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list,
Now we should be able to open the partially repaired table
to finish the repair in the handler later on.
*/
- if (!(table_list->table = reopen_name_locked_table(thd, table_list)))
+ pthread_mutex_lock(&LOCK_open);
+ if (reopen_name_locked_table(thd, table_list))
{
- pthread_mutex_lock(&LOCK_open);
unlock_table_name(thd, table_list);
pthread_mutex_unlock(&LOCK_open);
+ error= send_check_errmsg(thd, table_list, "repair",
+ "Failed to open partially repaired table");
+ goto end;
}
+ pthread_mutex_unlock(&LOCK_open);
end:
if (table == &tmp_table)