Hi!
On Jul 12, ramil@stripped wrote:
> ChangeSet@stripped, 2007-07-12 20:24:45+05:00, ramil@stripped +2 -0
> Fix for bug #29253: csv table reportedly marked as crashed
>
> Problem: the data file changes made during delete/update are not
> visible to parallel working threads as the file is reopened, so
> reading data with old descriptors might miss the changes.
>
> Fix: reopen the data file before reading if it was reopened during
> delete/update to ensure there's no data behind.
ok to push with two changes, see below
> diff -Nrup a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
> --- a/storage/csv/ha_tina.cc 2007-07-10 13:09:06 +05:00
> +++ b/storage/csv/ha_tina.cc 2007-07-12 20:24:42 +05:00
> @@ -985,6 +987,33 @@ int ha_tina::delete_row(const uchar * bu
>
> +/**
> + @brief Reopen the data file.
> +
> + @details Compare the local version of the data file with the shared one.
> + If they differ, there are some changes behind and we have to reopen
> + the data file to make the changes visible.
> + Call @c file_buff->init_buff() at the end to read the beginning of the
> + data file into buffer.
> + @retval 0 OK.
> + @retval 1 There was an error.
> +*/
> +
> +int ha_tina::reopen_data_file()
Pick a better name please. What this function does could be put in a
name like
reopen_data_file_if_necessary_and_call_init_buffer()
but I hope you could come up with a shorter name :)
> +{
> + if (local_data_file_version != share->data_file_version)
> + {
> + local_data_file_version= share->data_file_version;
> + if (my_close(data_file, MYF(0)) ||
> + (data_file= my_open(share->data_file_name, O_RDONLY, MYF(0))) == -1)
> + return 1;
> + }
> + file_buff->init_buff(data_file);
> + return 0;
> +}
> @@ -1247,6 +1275,15 @@ int ha_tina::rnd_end()
> if (((data_file= my_open(share->data_file_name, O_RDONLY, MYF(0))) == -1))
> DBUG_RETURN(-1);
> /*
> + As we reopen the data file, increase share->data_file_version
> + in order to force parallel running threads to reopen the data file.
csv does not support "parallel running threads", and if it would, you
patch would've been wrong.
Clarify the comment, you don't really mean "running" threads, but
threads waiting on a table lock.
> + That makes the latest changes become visible to them.
> + Update local_data_file_version as no need to reopen it in the
> + current thread.
> + */
> + share->data_file_version++;
> + local_data_file_version= share->data_file_version;
> + /*
> The datafile is consistent at this point and the write filedes is
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