summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.(none)>2007-07-16 22:34:36 +0400
committerunknown <kostja@bodhi.(none)>2007-07-16 22:34:36 +0400
commitb6c0fb605d613df14405e1d7c5621d22b35bc4fe (patch)
tree43232dd4626ea6056536d3070b8d15daece08763
parent146b0e14753c3e19451b04065b6d0f29d5a9a069 (diff)
downloadmariadb-git-b6c0fb605d613df14405e1d7c5621d22b35bc4fe.tar.gz
Fix ndb_cache* test failures in the -runtime tree.
Do not try to acquire structure_guard_mutex for the second time when invalidating a table from send_result_to_client. sql/sql_cache.cc: Do not try to acquire mutex when invalidating a table from send_result_to_client(). A follow up patch for the patch for Bug#21074. Reuse code by moving locking-independent invalidation functionality into invalidate_table_internal. sql/sql_cache.h: Add a new declaration.
-rw-r--r--sql/sql_cache.cc33
-rw-r--r--sql/sql_cache.h1
2 files changed, 26 insertions, 8 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index f7ad024c143..cab9ef94d6d 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1347,7 +1347,9 @@ def_week_frmt: %lu",
("Handler require invalidation queries of %s.%s %lu-%lu",
table_list.db, table_list.alias,
(ulong) engine_data, (ulong) table->engine_data()));
- invalidate_table(thd, (uchar *) table->db(), table->key_length());
+ invalidate_table_internal(thd,
+ (uchar *) table->db(),
+ table->key_length());
}
else
thd->lex->safe_to_cache_query= 0; // Don't try to cache this
@@ -2468,13 +2470,8 @@ void Query_cache::invalidate_table(THD *thd, uchar * key, uint32 key_length)
m_cache_status= Query_cache::TABLE_FLUSH_IN_PROGRESS;
STRUCT_UNLOCK(&structure_guard_mutex);
- Query_cache_block *table_block=
- (Query_cache_block*)hash_search(&tables, key, key_length);
- if (query_cache_size > 0 && table_block)
- {
- Query_cache_block_table *list_root= table_block->table(0);
- invalidate_query_block_list(thd, list_root);
- }
+ if (query_cache_size > 0)
+ invalidate_table_internal(thd, key, key_length);
STRUCT_LOCK(&structure_guard_mutex);
m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS;
@@ -2489,6 +2486,26 @@ void Query_cache::invalidate_table(THD *thd, uchar * key, uint32 key_length)
/**
+ Try to locate and invalidate a table by name.
+ The caller must ensure that no other thread is trying to work with
+ the query cache when this function is executed.
+
+ @pre structure_guard_mutex is acquired or TABLE_FLUSH_IN_PROGRESS is set.
+*/
+
+void
+Query_cache::invalidate_table_internal(THD *thd, uchar *key, uint32 key_length)
+{
+ Query_cache_block *table_block=
+ (Query_cache_block*)hash_search(&tables, key, key_length);
+ if (table_block)
+ {
+ Query_cache_block_table *list_root= table_block->table(0);
+ invalidate_query_block_list(thd, list_root);
+ }
+}
+
+/**
@brief Invalidate a linked list of query cache blocks.
Each block tries to aquire a block level lock before
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index cfc52e5d33a..c4c7e1dbc5e 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -279,6 +279,7 @@ private:
Cache_status m_cache_status;
void free_query_internal(Query_cache_block *point);
+ void invalidate_table_internal(THD *thd, uchar *key, uint32 key_length);
protected:
/*