1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +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.

sql/sql_base.cc:
  Use thd->LOCK_ha_data (systematically) to set
  thd->open_tables.
sql/sql_class.h:
  Implement THD::set_open_tables().
sql/sql_cursor.cc:
  Use thd->LOCK_ha_data (systematically) to set
  thd->open_tables.
sql/sql_handler.cc:
  Use thd->LOCK_ha_data (systematically) to set
  thd->open_tables.
  Acquisition of LOCK_open is moved inside close_thread_table().
sql/sql_table.cc:
  Acquisition of LOCK_open is moved inside close_thread_tables().
This commit is contained in:
Konstantin Osipov
2010-06-08 12:08:46 +04:00
parent 29f9fb7a0a
commit d4f1abaad2
5 changed files with 43 additions and 52 deletions

View File

@ -2682,6 +2682,12 @@ public:
void set_query_and_id(char *query_arg, uint32 query_length_arg,
query_id_t new_query_id);
void set_query_id(query_id_t new_query_id);
void set_open_tables(TABLE *open_tables_arg)
{
mysql_mutex_lock(&LOCK_thd_data);
open_tables= open_tables_arg;
mysql_mutex_unlock(&LOCK_thd_data);
}
void enter_locked_tables_mode(enum_locked_tables_mode mode_arg)
{
DBUG_ASSERT(locked_tables_mode == LTM_NONE);