Hi Sergey,
Sergey Glukhov wrote:
> #At file:///home/gluh/MySQL/bazaar/mysql-5.1-bug-36638/
>
> 2674 Sergey Glukhov 2008-08-05
> Bug#36638 mysqld crashes when open file limit is passed and general query log
> enabled
> The problem:
> CSV storage engine open function returns success even
> thought it failed to open the data file
> The fix:
> return error
> Additional fixes:
> added MY_WME to my_open to avoid mysterious error message
> free share struct if open the file was unsuccesful
> modified:
> mysql-test/r/csv.result
> mysql-test/t/csv.test
> storage/csv/ha_tina.cc
>
> per-file messages:
> mysql-test/r/csv.result
> test result
> mysql-test/t/csv.test
> test case
> added connection cleanup
> storage/csv/ha_tina.cc
> The problem:
> CSV storage engine open function returns success even
> thought it failed to open the data file
> The fix:
> return error
> Additional fixes:
> added MY_WME to my_open to avoid mysterious error message
> free share struct if open the file was unsuccesful
> === modified file 'mysql-test/r/csv.result'
> --- a/mysql-test/r/csv.result 2008-01-17 23:37:18 +0000
> +++ b/mysql-test/r/csv.result 2008-08-05 08:59:09 +0000
> @@ -5388,4 +5388,10 @@ select * from t1;
> c1
> That
> drop table t1;
> +create table t1 (a int not null) engine=csv;
> +lock tables t1 read;
> +select * from t1;
> +ERROR HY000: File './test/t1.CSV' not found (Errcode: 2)
> +unlock tables;
> +drop table t1;
> End of 5.1 tests
>
> === modified file 'mysql-test/t/csv.test'
> --- a/mysql-test/t/csv.test 2008-01-17 23:37:18 +0000
> +++ b/mysql-test/t/csv.test 2008-08-05 08:59:09 +0000
> @@ -1386,6 +1386,9 @@ UNLOCK TABLES;
>
> # cleanup
> DROP TABLE test_concurrent_insert;
> +connection default;
> +--disconnect con1
> +--disconnect con2
>
> #
> # Test REPAIR/CHECK TABLE (5.1)
> @@ -1784,4 +1787,19 @@ update t1 set c1="That" where c1="This";
> select * from t1;
> drop table t1;
>
> +#
> +# Bug#36638 mysqld crashes when open file limit is passed and general query log
> enabled
> +#
> +create table t1 (a int not null) engine=csv;
> +lock tables t1 read;
> +connect (con1,localhost,root,,);
> +--connection con1
> +--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.CSV
Add a comment: # EE_FILENOTFOUND 29
> +--error 29
> +select * from t1;
> +connection default;
> +unlock tables;
> +drop table t1;
> +--disconnect con1
> +
> --echo End of 5.1 tests
>
> === modified file 'storage/csv/ha_tina.cc'
> --- a/storage/csv/ha_tina.cc 2008-03-29 15:56:33 +0000
> +++ b/storage/csv/ha_tina.cc 2008-08-05 08:59:09 +0000
> @@ -191,7 +191,7 @@ static TINA_SHARE *get_share(const char
> meta-file in the end.
> */
> if ((share->meta_file= my_open(meta_file_name,
> - O_RDWR|O_CREAT, MYF(0))) == -1)
> + O_RDWR|O_CREAT, MYF(MY_WME))) == -1)
> share->crashed= TRUE;
The code below this will try to use share->meta_file even thought
the open failed. I think we could re-organize it to mark crashed
with a short-circuit evaluation between the open and read.
>
> /*
> @@ -342,7 +342,7 @@ int ha_tina::init_tina_writer()
> (void)write_meta_file(share->meta_file, share->rows_recorded, TRUE);
>
> if ((share->tina_write_filedes=
> - my_open(share->data_file_name, O_RDWR|O_APPEND, MYF(0))) == -1)
> + my_open(share->data_file_name, O_RDWR|O_APPEND, MYF(MY_WME))) == -1)
> {
> DBUG_PRINT("info", ("Could not open tina file writes"));
> share->crashed= TRUE;
> @@ -828,8 +828,12 @@ int ha_tina::open(const char *name, int
> }
>
> local_data_file_version= share->data_file_version;
> - if ((data_file= my_open(share->data_file_name, O_RDONLY, MYF(0))) == -1)
> - DBUG_RETURN(0);
> + if ((data_file= my_open(share->data_file_name,
> + O_RDONLY, MYF(MY_WME))) == -1)
> + {
> + free_share(share);
> + DBUG_RETURN(1);
I think it would be better to return my_errno as other engines do.
Something like: DBUG_RETURN (my_errno ? my_errno : -1);
-- Davi Arnaut