Commit 22062357 authored by unknown's avatar unknown

Fix possible race condition in Query cache.

parent 96340a40
...@@ -1312,7 +1312,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg) ...@@ -1312,7 +1312,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
{ {
BLOCK_LOCK_WR(block); BLOCK_LOCK_WR(block);
Query_cache_query *query= block->query(); Query_cache_query *query= block->query();
if (query && query->writer()) if (query->writer())
{ {
/* /*
Drop the writer; this will cancel any attempts to store Drop the writer; this will cancel any attempts to store
...@@ -1322,7 +1322,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg) ...@@ -1322,7 +1322,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
query->writer(0); query->writer(0);
refused++; refused++;
} }
BLOCK_UNLOCK_WR(block); query->unlock_n_destroy();
block= block->next; block= block->next;
} while (block != queries_blocks); } while (block != queries_blocks);
} }
...@@ -4247,11 +4247,11 @@ my_bool Query_cache::move_by_type(uchar **border, ...@@ -4247,11 +4247,11 @@ my_bool Query_cache::move_by_type(uchar **border,
size_t key_length; size_t key_length;
key=query_cache_query_get_key((uchar*) block, &key_length, 0); key=query_cache_query_get_key((uchar*) block, &key_length, 0);
my_hash_first(&queries, (uchar*) key, key_length, &record_idx); my_hash_first(&queries, (uchar*) key, key_length, &record_idx);
block->query()->unlock_n_destroy();
block->destroy();
// Move table of used tables // Move table of used tables
memmove((char*) new_block->table(0), (char*) block->table(0), memmove((char*) new_block->table(0), (char*) block->table(0),
ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table))); ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table)));
block->query()->unlock_n_destroy();
block->destroy();
new_block->init(len); new_block->init(len);
new_block->type=Query_cache_block::QUERY; new_block->type=Query_cache_block::QUERY;
new_block->used=used; new_block->used=used;
......
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