3895 Dmitry Lenev 2012-05-15
WL#5772 "Add partitioned Table Definition Cache to avoid
using LOCK_open and its derivatives in DML queries".
Review change #7:
- Adjust name of some methods to better reflect what they do.
- Make former static functions which are critical for performance
inline methods.
modified:
sql/sql_base.cc
sql/sql_base.h
sql/sql_test.cc
sql/table.cc
3894 Dmitry Lenev 2012-05-15
WL#5772 "Add partitioned Table Definition Cache to avoid
using LOCK_open and its derivatives in DML queries".
Review change #6:
Update description of --table-open-cache option to
better reflect its "new" meaning.
modified:
mysql-test/r/mysqld--help-notwin.result
mysql-test/r/mysqld--help-win.result
sql/sys_vars.cc
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2012-05-11 16:05:27 +0000
+++ b/sql/sql_base.cc 2012-05-15 15:10:59 +0000
@@ -344,11 +344,9 @@ uint Table_cache::cached_tables()
/**
Acquire locks on all instances of table cache and table definition
cache (i.e. LOCK_open).
-
- TODO: Come up with a better name!
*/
-void Table_cache::lock_all()
+void Table_cache::lock_all_and_tdc()
{
for (uint i= 0; i < table_cache_instances; i++)
mysql_mutex_lock(&m_table_cache[i].m_lock);
@@ -362,7 +360,7 @@ void Table_cache::lock_all()
cache.
*/
-void Table_cache::unlock_all()
+void Table_cache::unlock_all_and_tdc()
{
mysql_mutex_unlock(&LOCK_open);
@@ -372,8 +370,7 @@ void Table_cache::unlock_all()
/**
- Assert that caller owns locks on all instances of table cache
- and table definition cache.
+ Assert that caller owns locks on all instances of table cache.
*/
void Table_cache::assert_owner_all()
@@ -385,6 +382,19 @@ void Table_cache::assert_owner_all()
}
+/**
+ Assert that caller owns locks on all instances of table cache
+ and table definition cache.
+*/
+
+void Table_cache::assert_owner_all_and_tdc()
+{
+ assert_owner_all();
+
+ mysql_mutex_assert_owner(&LOCK_open);
+}
+
+
/** Acquire lock on table cache instance. */
void Table_cache::lock()
@@ -725,7 +735,7 @@ void table_def_start_shutdown(void)
{
if (table_def_inited)
{
- Table_cache::lock_all();
+ Table_cache::lock_all_and_tdc();
/*
Ensure that TABLE and TABLE_SHARE objects which are created for
tables that are open during process of plugins' shutdown are
@@ -733,7 +743,7 @@ void table_def_start_shutdown(void)
plugins minimal and allows shutdown to proceed smoothly.
*/
table_def_shutdown_in_progress= TRUE;
- Table_cache::unlock_all();
+ Table_cache::unlock_all_and_tdc();
/* Free all cached but unused TABLEs and TABLE_SHAREs. */
close_cached_tables(NULL, NULL, FALSE, LONG_TIMEOUT);
}
@@ -1330,7 +1340,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *t
start_list= &open_list;
open_list=0;
- Table_cache::lock_all();
+ Table_cache::lock_all_and_tdc();
for (uint idx=0 ; result == 0 && idx < table_def_cache.records; idx++)
{
@@ -1367,7 +1377,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *t
start_list= &(*start_list)->next;
*start_list=0;
}
- Table_cache::unlock_all();
+ Table_cache::unlock_all_and_tdc();
DBUG_RETURN(open_list);
}
@@ -1449,7 +1459,7 @@ static void kill_delayed_threads_for_tab
void Table_cache::free_all_unused_tables()
{
- Table_cache::assert_owner_all();
+ Table_cache::assert_owner_all_and_tdc();
for (uint i= 0; i < table_cache_instances; i++)
{
@@ -1491,7 +1501,7 @@ bool close_cached_tables(THD *thd, TABLE
DBUG_ENTER("close_cached_tables");
DBUG_ASSERT(thd || (!wait_for_refresh && !tables));
- Table_cache::lock_all();
+ Table_cache::lock_all_and_tdc();
if (!tables)
{
/*
@@ -1536,7 +1546,7 @@ bool close_cached_tables(THD *thd, TABLE
wait_for_refresh=0; // Nothing to wait for
}
- Table_cache::unlock_all();
+ Table_cache::unlock_all_and_tdc();
if (!wait_for_refresh)
DBUG_RETURN(result);
@@ -4475,13 +4485,13 @@ static bool auto_repair_table(THD *thd,
}
my_free(entry);
- Table_cache::lock_all();
+ Table_cache::lock_all_and_tdc();
release_table_share(share);
/* Remove the repaired share from the table cache. */
tdc_remove_table(thd, TDC_RT_REMOVE_ALL,
table_list->db, table_list->table_name,
TRUE);
- Table_cache::unlock_all();
+ Table_cache::unlock_all_and_tdc();
return result;
end_unlock:
mysql_mutex_unlock(&LOCK_open);
@@ -9676,9 +9686,9 @@ my_bool mysql_rm_tmp_tables(void)
void tdc_flush_unused_tables()
{
- Table_cache::lock_all();
+ Table_cache::lock_all_and_tdc();
Table_cache::free_all_unused_tables();
- Table_cache::unlock_all();
+ Table_cache::unlock_all_and_tdc();
}
@@ -9700,7 +9710,7 @@ void Table_cache::remove_table_all(THD *
enum_tdc_remove_table_type remove_type,
const char *key, uint key_length)
{
- Table_cache::assert_owner_all();
+ Table_cache::assert_owner_all_and_tdc();
for (uint i= 0; i < table_cache_instances; i++)
{
@@ -9775,9 +9785,9 @@ void tdc_remove_table(THD *thd, enum_tdc
TABLE_SHARE *share;
if (! has_lock)
- Table_cache::lock_all();
+ Table_cache::lock_all_and_tdc();
else
- Table_cache::assert_owner_all();
+ Table_cache::assert_owner_all_and_tdc();
DBUG_ASSERT(remove_type == TDC_RT_REMOVE_UNUSED ||
thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, table_name,
@@ -9809,7 +9819,7 @@ void tdc_remove_table(THD *thd, enum_tdc
}
if (! has_lock)
- Table_cache::unlock_all();
+ Table_cache::unlock_all_and_tdc();
}
=== modified file 'sql/sql_base.h'
--- a/sql/sql_base.h 2012-05-11 16:05:27 +0000
+++ b/sql/sql_base.h 2012-05-15 15:10:59 +0000
@@ -741,21 +741,22 @@ public:
static uint cached_tables();
- static void lock_all();
- static void unlock_all();
+ static void lock_all_and_tdc();
+ static void unlock_all_and_tdc();
static void assert_owner_all();
+ static void assert_owner_all_and_tdc();
inline void lock();
inline void unlock();
- TABLE* get_table(THD *thd, my_hash_value_type hash_value,
- const char *key, uint key_length,
- TABLE_SHARE **share);
+ inline TABLE* get_table(THD *thd, my_hash_value_type hash_value,
+ const char *key, uint key_length,
+ TABLE_SHARE **share);
- void release_table(THD *thd, TABLE *table);
+ inline void release_table(THD *thd, TABLE *table);
- bool add_used_table(THD *thd, TABLE *table);
- void remove_table(TABLE *table);
+ inline bool add_used_table(THD *thd, TABLE *table);
+ inline void remove_table(TABLE *table);
static void remove_table_all(THD *thd,
enum_tdc_remove_table_type remove_type,
=== modified file 'sql/sql_test.cc'
--- a/sql/sql_test.cc 2012-05-11 16:05:27 +0000
+++ b/sql/sql_test.cc 2012-05-15 15:10:59 +0000
@@ -86,7 +86,7 @@ static void print_cached_tables(void)
compile_time_assert(TL_WRITE_ONLY+1 == array_elements(lock_descriptions));
/* purecov: begin tested */
- Table_cache::lock_all();
+ Table_cache::lock_all_and_tdc();
Table_cache::print_tables_all();
@@ -94,7 +94,7 @@ static void print_cached_tables(void)
if (my_hash_check(&table_def_cache))
printf("Error: Table definition hash table is corrupted\n");
fflush(stdout);
- Table_cache::unlock_all();
+ Table_cache::unlock_all_and_tdc();
/* purecov: end */
return;
}
=== modified file 'sql/table.cc'
--- a/sql/table.cc 2012-05-11 16:05:27 +0000
+++ b/sql/table.cc 2012-05-15 15:10:59 +0000
@@ -3243,7 +3243,7 @@ bool TABLE_SHARE::visit_subgraph(Wait_fo
if (gvisitor->m_lock_open_count++ == 0)
{
locked= TRUE;
- Table_cache::lock_all();
+ Table_cache::lock_all_and_tdc();
}
Table_cache_iterator tables_it(this);
@@ -3289,7 +3289,7 @@ end:
if (locked)
{
DBUG_ASSERT(gvisitor->m_lock_open_count == 0);
- Table_cache::unlock_all();
+ Table_cache::unlock_all_and_tdc();
}
return result;
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (Dmitry.Lenev:3894 to 3895) WL#5772 | Dmitry Lenev | 16 May |