Hi!
On Jul 11, kpettersson@stripped wrote:
> ChangeSet@stripped, 2007-07-11 08:46:56+02:00, thek@adventure.(none) +5 -0
> Bug#28249 Query Cache returns wrong result with concurrent insert / certain lock
>
> A race condition in the integration between MyISAM and the query cache code
> caused the query cache to fail to invalidate itself on concurrently inserted
> data.
>
> This patch fix this problem by using the existing handler interface which, upon
> each statement cache attempt, compare the size of the table as viewed from the
> cache writing thread and with any snap shot of the global table state. If the
> two sizes are different the global table size is unknown and the current
> statement can't be cached.
Good, thanks.
Ok to push with one change, see below
> --- 1.178/sql/ha_myisam.cc 2007-03-28 10:22:20 +02:00
> +++ 1.179/sql/ha_myisam.cc 2007-07-11 08:46:54 +02:00
...
> +
> + actual_data_file_length= file->s->state.state.data_file_length;
> + current_data_file_length= file->save_state.data_file_length;
Okay, but during a discussion of this mutex issue, I realized that it's
less than trivial why a mutex is not required here. Please add a comment
above the actual_data_file_length assignment:
/*
POSIX visibility rules specify that "2. Whatever memory values a
thread can see when it unlocks a mutex <...> can also be seen by any
thread that later locks the same mutex". In this particular case,
concurrent insert thread had modified the data_file_length in
MYISAM_SHARE before it has unlocked (or even locked)
structure_guard_mutex. So, here we're guaranteed to see at least that
value after we've locked the same mutex. We can see a later value
(modified by some other thread) though, but it's ok, as we only want
to know if the variable was changed, the actual new value doesn't matter
*/
Regards / Mit vielen Grüssen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Developer
/_/ /_/\_, /___/\___\_\___/ MySQL GmbH, Radlkoferstr. 2, D-81373 München
<___/ Geschäftsführer: Kaj Arnö - HRB
München 162140