summaryrefslogtreecommitdiff
path: root/sql/sql_handler.cc
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2010-06-08 12:08:46 +0400
committerKonstantin Osipov <kostja@sun.com>2010-06-08 12:08:46 +0400
commit4b6b69d22e33b1fadf1546492b17c81dfed20766 (patch)
tree978ecf18fe2aed14f3a694a73e5a80f1c7835be3 /sql/sql_handler.cc
parent5196821127d48dcf767c1751570b2a8a468bc5f3 (diff)
downloadmariadb-git-4b6b69d22e33b1fadf1546492b17c81dfed20766.tar.gz
WL#4441 "LOCK_open: Remove requirement of mutex protecting
thd->open_tables" thd->open_tables list is not normally accessed concurrently except for one case: when the connection has open SQL HANDLER tables, and we want to perform a DDL on the table, we want to abort waits on MyISAM thr_lock of those connections that prevent the DDL from proceeding, and iterate over thd->open_tables list to find out the tables on which the thread is waiting. In 5.5 we mostly use deadlock detection and soft deadlock prevention, as opposed to "hard" deadlock prevention of 5.1, which would abort any transaction that may cause a deadlock. The only remaining case when neither deadlock detection nor deadlock prevention is implemented in 5.5 is HANDLER SQL, where we use old good thr_lock_abort() technique form 5.1. Thus, replace use of LOCK_open to protect thd->open_tables with thd->LOCK_ha_data (a lock protecting various session private data). This is a port of the work done for 5.5.4 for review and inclusion into 5.5.5.
Diffstat (limited to 'sql/sql_handler.cc')
-rw-r--r--sql/sql_handler.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 23177b8f51a..d07c7eaa277 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -131,13 +131,11 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables)
/* Non temporary table. */
tables->table->file->ha_index_or_rnd_end();
tables->table->open_by_handler= 0;
- mysql_mutex_lock(&LOCK_open);
if (close_thread_table(thd, &tables->table))
{
/* Tell threads waiting for refresh that something has happened */
broadcast_refresh();
}
- mysql_mutex_unlock(&LOCK_open);
thd->mdl_context.release_lock(tables->mdl_request.ticket);
}
else if (tables->table)
@@ -278,7 +276,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
See open_table() back-off comments for more details.
*/
backup_open_tables= thd->open_tables;
- thd->open_tables= NULL;
+ thd->set_open_tables(NULL);
mdl_savepoint= thd->mdl_context.mdl_savepoint();
/*
@@ -312,7 +310,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
if (error)
{
close_thread_tables(thd);
- thd->open_tables= backup_open_tables;
+ thd->set_open_tables(backup_open_tables);
thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
if (!reopen)
my_hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables);
@@ -325,7 +323,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
DBUG_PRINT("exit",("ERROR"));
DBUG_RETURN(TRUE);
}
- thd->open_tables= backup_open_tables;
+ thd->set_open_tables(backup_open_tables);
if (hash_tables->mdl_request.ticket)
{
thd->mdl_context.
@@ -559,7 +557,7 @@ retry:
mysql_lock_tables() needs thd->open_tables to be set correctly to
be able to handle aborts properly.
*/
- thd->open_tables= hash_tables->table;
+ thd->set_open_tables(hash_tables->table);
sql_handler_lock_error.init();
@@ -575,7 +573,7 @@ retry:
*/
DBUG_ASSERT(hash_tables->table == thd->open_tables);
/* Restore previous context. */
- thd->open_tables= backup_open_tables;
+ thd->set_open_tables(backup_open_tables);
if (sql_handler_lock_error.need_reopen())
{