Commit 36f1e91b authored by timour@mysql.com's avatar timour@mysql.com

Merge of fix for BUG#4258 from 4.1.

Needs additional manual merge.
parents 10c49778 b266ad2c
...@@ -88,12 +88,13 @@ typedef struct st_key_cache ...@@ -88,12 +88,13 @@ typedef struct st_key_cache
ulong param_division_limit; /* min. percentage of warm blocks */ ulong param_division_limit; /* min. percentage of warm blocks */
ulong param_age_threshold; /* determines when hot block is downgraded */ ulong param_age_threshold; /* determines when hot block is downgraded */
/* Statistics variables */ /* Statistics variables. These are reset in reset_key_cache_counters(). */
ulong global_blocks_changed; /* number of currently dirty blocks */ ulong global_blocks_changed; /* number of currently dirty blocks */
ulong global_cache_w_requests;/* number of write requests (write hits) */ ulong global_cache_w_requests;/* number of write requests (write hits) */
ulong global_cache_write; /* number of writes from the cache to files */ ulong global_cache_write; /* number of writes from the cache to files */
ulong global_cache_r_requests;/* number of read requests (read hits) */ ulong global_cache_r_requests;/* number of read requests (read hits) */
ulong global_cache_read; /* number of reads from files to the cache */ ulong global_cache_read; /* number of reads from files to the cache */
int blocks; /* max number of blocks in the cache */ int blocks; /* max number of blocks in the cache */
my_bool in_init; /* Set to 1 in MySQL during init/resize */ my_bool in_init; /* Set to 1 in MySQL during init/resize */
} KEY_CACHE; } KEY_CACHE;
...@@ -132,5 +133,7 @@ extern my_bool multi_key_cache_set(const byte *key, uint length, ...@@ -132,5 +133,7 @@ extern my_bool multi_key_cache_set(const byte *key, uint length,
KEY_CACHE *key_cache); KEY_CACHE *key_cache);
extern void multi_key_cache_change(KEY_CACHE *old_data, extern void multi_key_cache_change(KEY_CACHE *old_data,
KEY_CACHE *new_data); KEY_CACHE *new_data);
extern int reset_key_cache_counters(const char *name,
KEY_CACHE *key_cache);
C_MODE_END C_MODE_END
#endif /* _keycache_h */ #endif /* _keycache_h */
...@@ -2444,6 +2444,41 @@ static int flush_all_key_blocks(KEY_CACHE *keycache) ...@@ -2444,6 +2444,41 @@ static int flush_all_key_blocks(KEY_CACHE *keycache)
} }
/*
Reset the counters of a key cache.
SYNOPSIS
reset_key_cache_counters()
name the name of a key cache
key_cache pointer to the key kache to be reset
DESCRIPTION
This procedure is used by process_key_caches() to reset the counters of all
currently used key caches, both the default one and the named ones.
RETURN
0 on success (always because it can't fail)
*/
int reset_key_cache_counters(const char *name, KEY_CACHE *key_cache)
{
DBUG_ENTER("reset_key_cache_counters");
if (!key_cache->key_cache_inited)
{
DBUG_PRINT("info", ("Key cache %s not initialized.", name));
DBUG_RETURN(0);
}
DBUG_PRINT("info", ("Resetting counters for key cache %s.", name));
key_cache->global_blocks_changed= 0; /* Key_blocks_not_flushed */
key_cache->global_cache_r_requests= 0; /* Key_read_requests */
key_cache->global_cache_read= 0; /* Key_reads */
key_cache->global_cache_w_requests= 0; /* Key_write_requests */
key_cache->global_cache_write= 0; /* Key_writes */
DBUG_RETURN(0);
}
#ifndef DBUG_OFF #ifndef DBUG_OFF
/* /*
Test if disk-cache is ok Test if disk-cache is ok
......
...@@ -1064,7 +1064,6 @@ extern struct system_variables global_system_variables; ...@@ -1064,7 +1064,6 @@ extern struct system_variables global_system_variables;
extern struct system_variables max_system_variables; extern struct system_variables max_system_variables;
extern struct system_status_var global_status_var; extern struct system_status_var global_status_var;
extern struct rand_struct sql_rand; extern struct rand_struct sql_rand;
extern KEY_CACHE *sql_key_cache;
extern const char *opt_date_time_formats[]; extern const char *opt_date_time_formats[];
extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[]; extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
......
...@@ -395,7 +395,6 @@ struct system_status_var global_status_var; ...@@ -395,7 +395,6 @@ struct system_status_var global_status_var;
MY_TMPDIR mysql_tmpdir_list; MY_TMPDIR mysql_tmpdir_list;
MY_BITMAP temp_pool; MY_BITMAP temp_pool;
KEY_CACHE *sql_key_cache;
CHARSET_INFO *system_charset_info, *files_charset_info ; CHARSET_INFO *system_charset_info, *files_charset_info ;
CHARSET_INFO *national_charset_info, *table_alias_charset; CHARSET_INFO *national_charset_info, *table_alias_charset;
...@@ -1867,14 +1866,14 @@ We will try our best to scrape up some info that will hopefully help diagnose\n\ ...@@ -1867,14 +1866,14 @@ We will try our best to scrape up some info that will hopefully help diagnose\n\
the problem, but since we have already crashed, something is definitely wrong\n\ the problem, but since we have already crashed, something is definitely wrong\n\
and this may fail.\n\n"); and this may fail.\n\n");
fprintf(stderr, "key_buffer_size=%lu\n", fprintf(stderr, "key_buffer_size=%lu\n",
(ulong) sql_key_cache->key_cache_mem_size); (ulong) dflt_key_cache->key_cache_mem_size);
fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size); fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size);
fprintf(stderr, "max_used_connections=%ld\n", max_used_connections); fprintf(stderr, "max_used_connections=%ld\n", max_used_connections);
fprintf(stderr, "max_connections=%ld\n", max_connections); fprintf(stderr, "max_connections=%ld\n", max_connections);
fprintf(stderr, "threads_connected=%d\n", thread_count); fprintf(stderr, "threads_connected=%d\n", thread_count);
fprintf(stderr, "It is possible that mysqld could use up to \n\ fprintf(stderr, "It is possible that mysqld could use up to \n\
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\
bytes of memory\n", ((ulong) sql_key_cache->key_cache_mem_size + bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
(global_system_variables.read_buff_size + (global_system_variables.read_buff_size +
global_system_variables.sortbuff_size) * global_system_variables.sortbuff_size) *
max_connections)/ 1024); max_connections)/ 1024);
...@@ -2141,12 +2140,12 @@ extern "C" void *signal_hand(void *arg __attribute__((unused))) ...@@ -2141,12 +2140,12 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
case SIGHUP: case SIGHUP:
if (!abort_loop) if (!abort_loop)
{ {
mysql_print_status((THD*) 0); // Print some debug info
reload_acl_and_cache((THD*) 0, reload_acl_and_cache((THD*) 0,
(REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST | (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
REFRESH_GRANT | REFRESH_GRANT |
REFRESH_THREADS | REFRESH_HOSTS), REFRESH_THREADS | REFRESH_HOSTS),
(TABLE_LIST*) 0, NULL); // Flush logs (TABLE_LIST*) 0, NULL); // Flush logs
mysql_print_status((THD*) 0); // Send debug some info
} }
break; break;
#ifdef USE_ONE_SIGNAL_HAND #ifdef USE_ONE_SIGNAL_HAND
...@@ -2820,8 +2819,6 @@ server."); ...@@ -2820,8 +2819,6 @@ server.");
/* call ha_init_key_cache() on all key caches to init them */ /* call ha_init_key_cache() on all key caches to init them */
process_key_caches(&ha_init_key_cache); process_key_caches(&ha_init_key_cache);
/* We must set dflt_key_cache in case we are using ISAM tables */
dflt_key_cache= sql_key_cache;
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY) #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY)
if (locked_in_memory && !getuid()) if (locked_in_memory && !getuid())
...@@ -5875,10 +5872,10 @@ static void mysql_init_variables(void) ...@@ -5875,10 +5872,10 @@ static void mysql_init_variables(void)
threads.empty(); threads.empty();
thread_cache.empty(); thread_cache.empty();
key_caches.empty(); key_caches.empty();
multi_keycache_init(); if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str,
if (!(sql_key_cache= get_or_create_key_cache(default_key_cache_base.str,
default_key_cache_base.length))) default_key_cache_base.length)))
exit(1); exit(1);
multi_keycache_init(); /* set key_cache_hash.default_value = dflt_key_cache */
/* Initialize structures that is used when processing options */ /* Initialize structures that is used when processing options */
replicate_rewrite_db.empty(); replicate_rewrite_db.empty();
......
...@@ -2232,7 +2232,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) ...@@ -2232,7 +2232,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
if (!tmp) // Zero size means delete if (!tmp) // Zero size means delete
{ {
if (key_cache == sql_key_cache) if (key_cache == dflt_key_cache)
goto end; // Ignore default key cache goto end; // Ignore default key cache
if (key_cache->key_cache_inited) // If initied if (key_cache->key_cache_inited) // If initied
...@@ -2246,7 +2246,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) ...@@ -2246,7 +2246,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
base_name->length, &list); base_name->length, &list);
key_cache->in_init= 1; key_cache->in_init= 1;
pthread_mutex_unlock(&LOCK_global_system_variables); pthread_mutex_unlock(&LOCK_global_system_variables);
error= reassign_keycache_tables(thd, key_cache, sql_key_cache); error= reassign_keycache_tables(thd, key_cache, dflt_key_cache);
pthread_mutex_lock(&LOCK_global_system_variables); pthread_mutex_lock(&LOCK_global_system_variables);
key_cache->in_init= 0; key_cache->in_init= 0;
} }
......
...@@ -5867,6 +5867,7 @@ void kill_one_thread(THD *thd, ulong id, bool only_kill_query) ...@@ -5867,6 +5867,7 @@ void kill_one_thread(THD *thd, ulong id, bool only_kill_query)
my_error(error, MYF(0), id); my_error(error, MYF(0), id);
} }
/* Clear most status variables */ /* Clear most status variables */
static void refresh_status(void) static void refresh_status(void)
...@@ -5876,17 +5877,6 @@ static void refresh_status(void) ...@@ -5876,17 +5877,6 @@ static void refresh_status(void)
{ {
if (ptr->type == SHOW_LONG) if (ptr->type == SHOW_LONG)
*(ulong*) ptr->value= 0; *(ulong*) ptr->value= 0;
else if (ptr->type == SHOW_KEY_CACHE_LONG)
{
/*
Reset value in 'default' key cache.
This needs to be recoded when we have thread specific key values
*/
char *value= (((char*) sql_key_cache) +
(uint) ((char*) (ptr->value) -
(char*) &dflt_key_cache_var));
*(ulong*) value= 0;
}
else if (ptr->type == SHOW_LONG_STATUS) else if (ptr->type == SHOW_LONG_STATUS)
{ {
THD *thd= current_thd; THD *thd= current_thd;
...@@ -5895,6 +5885,8 @@ static void refresh_status(void) ...@@ -5895,6 +5885,8 @@ static void refresh_status(void)
bzero((char*) &thd->status_var, sizeof(thd->status_var)); bzero((char*) &thd->status_var, sizeof(thd->status_var));
} }
} }
/* Reset the counters of all key caches (default and named). */
process_key_caches(reset_key_cache_counters);
pthread_mutex_unlock(&LOCK_status); pthread_mutex_unlock(&LOCK_status);
} }
......
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