Commit e54f7400 authored by igor@rurik.mysql.com's avatar igor@rurik.mysql.com

mf_keycache.c:

  Fixed typo that caused blocking key cache usage after resize.
  Removed wrong re-initialization of resize queue in init_key_cache.
parent 413f6b2f
...@@ -141,9 +141,9 @@ KEY_CACHE *dflt_key_cache= &dflt_key_cache_var; ...@@ -141,9 +141,9 @@ KEY_CACHE *dflt_key_cache= &dflt_key_cache_var;
#define FLUSH_CACHE 2000 /* sort this many blocks at once */ #define FLUSH_CACHE 2000 /* sort this many blocks at once */
static int flush_all_key_blocks(KEY_CACHE *keycache); static int flush_all_key_blocks(KEY_CACHE *keycache);
static inline void link_into_queue(KEYCACHE_WQUEUE *wqueue, static void link_into_queue(KEYCACHE_WQUEUE *wqueue,
struct st_my_thread_var *thread); struct st_my_thread_var *thread);
static inline void unlink_from_queue(KEYCACHE_WQUEUE *wqueue, static void unlink_from_queue(KEYCACHE_WQUEUE *wqueue,
struct st_my_thread_var *thread); struct st_my_thread_var *thread);
static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block); static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block);
static void test_key_cache(KEY_CACHE *keycache, static void test_key_cache(KEY_CACHE *keycache,
...@@ -192,8 +192,8 @@ static long keycache_thread_id; ...@@ -192,8 +192,8 @@ static long keycache_thread_id;
KEYCACHE_DBUG_PRINT(l,("|thread %ld",keycache_thread_id)) KEYCACHE_DBUG_PRINT(l,("|thread %ld",keycache_thread_id))
#define KEYCACHE_THREAD_TRACE_BEGIN(l) \ #define KEYCACHE_THREAD_TRACE_BEGIN(l) \
{ struct st_my_thread_var *thread_var =my_thread_var; \ { struct st_my_thread_var *thread_var= my_thread_var; \
keycache_thread_id=my_thread_var->id; \ keycache_thread_id= my_thread_var->id; \
KEYCACHE_DBUG_PRINT(l,("[thread %ld",keycache_thread_id)) } KEYCACHE_DBUG_PRINT(l,("[thread %ld",keycache_thread_id)) }
#define KEYCACHE_THREAD_TRACE_END(l) \ #define KEYCACHE_THREAD_TRACE_END(l) \
...@@ -289,6 +289,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ...@@ -289,6 +289,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
keycache->key_cache_inited= 1; keycache->key_cache_inited= 1;
keycache->in_init= 0; keycache->in_init= 0;
pthread_mutex_init(&keycache->cache_lock, MY_MUTEX_INIT_FAST); pthread_mutex_init(&keycache->cache_lock, MY_MUTEX_INIT_FAST);
keycache->resize_queue.last_thread= NULL;
} }
keycache->key_cache_mem_size= use_mem; keycache->key_cache_mem_size= use_mem;
...@@ -374,7 +375,6 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ...@@ -374,7 +375,6 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
keycache->cnt_for_resize_op= 0; keycache->cnt_for_resize_op= 0;
keycache->resize_in_flush= 0; keycache->resize_in_flush= 0;
keycache->can_be_used= 1; keycache->can_be_used= 1;
keycache->resize_queue.last_thread= NULL;
keycache->waiting_for_hash_link.last_thread= NULL; keycache->waiting_for_hash_link.last_thread= NULL;
keycache->waiting_for_block.last_thread= NULL; keycache->waiting_for_block.last_thread= NULL;
...@@ -464,7 +464,7 @@ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ...@@ -464,7 +464,7 @@ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
keycache_pthread_mutex_lock(&keycache->cache_lock); keycache_pthread_mutex_lock(&keycache->cache_lock);
wqueue= &keycache->resize_queue; wqueue= &keycache->resize_queue;
thread=my_thread_var; thread= my_thread_var;
link_into_queue(wqueue, thread); link_into_queue(wqueue, thread);
while (wqueue->last_thread->next != thread) while (wqueue->last_thread->next != thread)
...@@ -478,6 +478,7 @@ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ...@@ -478,6 +478,7 @@ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
/* TODO: if this happens, we should write a warning in the log file ! */ /* TODO: if this happens, we should write a warning in the log file ! */
keycache->resize_in_flush= 0; keycache->resize_in_flush= 0;
blocks= 0; blocks= 0;
keycache->can_be_used= 0;
goto finish; goto finish;
} }
keycache->resize_in_flush= 0; keycache->resize_in_flush= 0;
...@@ -497,8 +498,6 @@ finish: ...@@ -497,8 +498,6 @@ finish:
/* Signal for the next resize request to proceeed if any */ /* Signal for the next resize request to proceeed if any */
if (wqueue->last_thread) if (wqueue->last_thread)
keycache_pthread_cond_signal(&wqueue->last_thread->next->suspend); keycache_pthread_cond_signal(&wqueue->last_thread->next->suspend);
keycache->can_be_used= blocks <= 0;
keycache_pthread_mutex_unlock(&keycache->cache_lock); keycache_pthread_mutex_unlock(&keycache->cache_lock);
return blocks; return blocks;
} }
...@@ -733,8 +732,8 @@ static inline void add_to_queue(KEYCACHE_WQUEUE *wqueue, ...@@ -733,8 +732,8 @@ static inline void add_to_queue(KEYCACHE_WQUEUE *wqueue,
static void release_queue(KEYCACHE_WQUEUE *wqueue) static void release_queue(KEYCACHE_WQUEUE *wqueue)
{ {
struct st_my_thread_var *last=wqueue->last_thread; struct st_my_thread_var *last= wqueue->last_thread;
struct st_my_thread_var *next=last->next; struct st_my_thread_var *next= last->next;
struct st_my_thread_var *thread; struct st_my_thread_var *thread;
do do
{ {
...@@ -1052,7 +1051,7 @@ static inline void remove_reader(BLOCK_LINK *block) ...@@ -1052,7 +1051,7 @@ static inline void remove_reader(BLOCK_LINK *block)
static inline void wait_for_readers(KEY_CACHE *keycache, BLOCK_LINK *block) static inline void wait_for_readers(KEY_CACHE *keycache, BLOCK_LINK *block)
{ {
struct st_my_thread_var *thread=my_thread_var; struct st_my_thread_var *thread= my_thread_var;
while (block->hash_link->requests) while (block->hash_link->requests)
{ {
block->condvar= &thread->suspend; block->condvar= &thread->suspend;
......
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