1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
Konstantin Osipov
2010-06-08 12:08:46 +04:00
parent 5196821127
commit 4b6b69d22e
5 changed files with 43 additions and 52 deletions

View File

@ -357,7 +357,7 @@ void
Sensitive_cursor::reset_thd(THD *thd)
{
thd->derived_tables= 0;
thd->open_tables= 0;
thd->set_open_tables(NULL);
thd->lock= 0;
thd->free_list= 0;
thd->change_list.empty();
@ -436,7 +436,7 @@ Sensitive_cursor::fetch(ulong num_rows)
thd->lock == 0);
thd->derived_tables= derived_tables;
thd->open_tables= open_tables;
thd->set_open_tables(open_tables);
thd->lock= lock;
thd->set_query_id(query_id);
change_list.move_elements_to(&thd->change_list);
@ -519,14 +519,14 @@ Sensitive_cursor::close()
TABLE *tmp_derived_tables= thd->derived_tables;
MYSQL_LOCK *tmp_lock= thd->lock;
thd->open_tables= open_tables;
thd->set_open_tables(open_tables);
thd->derived_tables= derived_tables;
thd->lock= lock;
/* Is expected to at least close tables and empty thd->change_list */
stmt_arena->cleanup_stmt();
thd->open_tables= tmp_derived_tables;
thd->set_open_tables(tmp_derived_tables);
thd->derived_tables= tmp_derived_tables;
thd->lock= tmp_lock;
}