Hello,
Ingo Struewing a écrit, Le 03.04.2009 11:44:
> #At file:///home2/mydev/bzrroot/mysql-6.0-keycache-1/ based on
> revid:jorgen.loland@stripped
>
> 2810 Ingo Struewing 2009-04-03
> Bug#44068 - RESTORE can disable the MyISAM Key Cache
>
> The test case myisam_keycache_coverage used to fail if it ran
> after backup_myisam_sync.
>
> The reason was that the latter test case disabled the key cache
> during RESTORE. The error injection in myisam_keycache_coverage
> became void as the key cache wasn't used any more. Reads of the
> index file bypassed the cache, and the statements succeeded.
(... yes, I'm whipping myself now - ouch, ouch, ouch ... )
> Additional change: To make the state of the key cache visible,
> I added cleanup for the status variables blocks_used and
> blocks_unused. This improves the testability.
Ok.
> === modified file 'mysql-test/t/myisam_keycache_coverage.test'
> --- a/mysql-test/t/myisam_keycache_coverage.test 2009-03-30 16:47:55 +0000
> +++ b/mysql-test/t/myisam_keycache_coverage.test 2009-04-03 09:44:39 +0000
> @@ -5,6 +5,9 @@
> --source include/have_debug.inc
>
> --disable_warnings
> +# Reset debug server variable
> +SET GLOBAL debug='';
> +SET debug='';
For what problem does this help?
What happens if I run the testsuite with --debug, does the test reset
"debug" to what it was at start?
> === modified file 'mysys/mf_keycache.c'
> --- a/mysys/mf_keycache.c 2009-01-29 21:17:59 +0000
> +++ b/mysys/mf_keycache.c 2009-04-03 09:44:39 +0000
> @@ -765,6 +765,13 @@ void end_key_cache(KEY_CACHE *keycache,
> (ulong) keycache->global_cache_r_requests,
> (ulong) keycache->global_cache_read));
>
> + /*
> + Reset these values to be able to detect a disabled key cache.
> + See Bug#44068 (RESTORE can disable the MyISAM Key Cache).
> + */
> + keycache->blocks_used= 0;
> + keycache->blocks_unused= 0;
This also resets counters if this is an online resize (cleanup==0),
which is fine.
> if (cleanup)
> {
> pthread_mutex_destroy(&keycache->cache_lock);
> === modified file 'storage/myisam/mi_examine_log.c'
> --- a/storage/myisam/mi_examine_log.c 2009-02-22 18:02:16 +0000
> +++ b/storage/myisam/mi_examine_log.c 2009-04-03 09:44:39 +0000
> @@ -208,8 +209,13 @@ int mi_examine_log(MI_EXAMINE_LOG_PARAM
> bzero(mi_exl->com_count,sizeof(mi_exl->com_count));
> init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1,
> (tree_element_free) file_info_free, NULL);
> - (void) init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE,
> - 0, 0);
> + /*
> + init_key_cache() returns the number of cache blocks allocated, if
> + *this* call allocated them. If the function fails, or if the cache
> + was already initialized before, it returns zero.
> + */
> + key_cache_blocks= init_key_cache(dflt_key_cache, KEY_CACHE_BLOCK_SIZE,
> + KEY_CACHE_SIZE, 0, 0);
That would work.
Have you considered this alternative (which I prefer):
- mi_examine_log() is used from myisamlog or from mysqld
- in mysqld, key cache is initialized already
- so, just move the init_key_cache()/end_key_cache() calls to
myisamlog.c and leave mi_examine_log.c untouched
?
myisamchk follows this logic already: init/end are in myisamchk.c, not
mi_check.c. The functions in mi_check.c don't do "automagic init/end of
key cache".
Unrelated note: you don't need to patch Maria, I propagate MyISAM
changes to Maria (that is, after you have merged your team tree into
6.0-main, I merge 6.0-main into 6.0-maria and replicate all new MyISAM
changes to Maria). Of course, you *can* patch Maria if you prefer.
--
Mr. Guilhem Bichot <guilhem@stripped>
Sun Microsystems / MySQL, Lead Software Engineer
Bordeaux, France
www.sun.com / www.mysql.com