Commit 06d656b8 authored by kostja@bodhi.(none)'s avatar kostja@bodhi.(none)

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.
parent be4f73c4
...@@ -1347,7 +1347,9 @@ def_week_frmt: %lu", ...@@ -1347,7 +1347,9 @@ def_week_frmt: %lu",
("Handler require invalidation queries of %s.%s %lu-%lu", ("Handler require invalidation queries of %s.%s %lu-%lu",
table_list.db, table_list.alias, table_list.db, table_list.alias,
(ulong) engine_data, (ulong) table->engine_data())); (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 else
thd->lex->safe_to_cache_query= 0; // Don't try to cache this 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) ...@@ -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; m_cache_status= Query_cache::TABLE_FLUSH_IN_PROGRESS;
STRUCT_UNLOCK(&structure_guard_mutex); STRUCT_UNLOCK(&structure_guard_mutex);
Query_cache_block *table_block= if (query_cache_size > 0)
(Query_cache_block*)hash_search(&tables, key, key_length); invalidate_table_internal(thd, 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);
}
STRUCT_LOCK(&structure_guard_mutex); STRUCT_LOCK(&structure_guard_mutex);
m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS; m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS;
...@@ -2488,6 +2485,26 @@ void Query_cache::invalidate_table(THD *thd, uchar * key, uint32 key_length) ...@@ -2488,6 +2485,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. @brief Invalidate a linked list of query cache blocks.
......
...@@ -279,6 +279,7 @@ private: ...@@ -279,6 +279,7 @@ private:
Cache_status m_cache_status; Cache_status m_cache_status;
void free_query_internal(Query_cache_block *point); void free_query_internal(Query_cache_block *point);
void invalidate_table_internal(THD *thd, uchar *key, uint32 key_length);
protected: protected:
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment