Bug #29322 | create table partition datadir to existing file => crash | ||
---|---|---|---|
Submitted: | 24 Jun 2007 12:31 | Modified: | 6 Jul 2007 10:30 |
Reporter: | Martin Friebe (Gold Quality Contributor) (OCA) | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 5.1.20bk | OS: | FreeBSD |
Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
Tags: | crash, data directory, partition, qc |
[24 Jun 2007 12:31]
Martin Friebe
[24 Jun 2007 12:33]
Martin Friebe
to reproduce, please replace /mysqldata/ with the correct data path. show variables like 'datadir';
[24 Jun 2007 12:58]
Valeriy Kravchuk
Thank you for a problem report. Sorry, but I've got no crash with latest 5.0.20-debug on Linux: openxs@linux:~/dbs/5.1> bin/mysql -uroot test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.20-beta-debug Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database db1; Query OK, 1 row affected (0.04 sec) mysql> create database db2; Query OK, 1 row affected (0.00 sec) mysql> mysql> use db1; Database changed mysql> drop table if exists t1; Query OK, 0 rows affected, 1 warning (0.01 sec) CREATE TABLE t1 (a INT) PARTITION BY RANGE ( a ) mysql> CREATE TABLE t1 (a INT) PARTITION BY RANGE ( a ) -> ( PARTITION p0 VALUES LESS THAN (10) , -> PARTITION p1 VALUES LESS THAN (20) -> ); use db2; drop table if exists t1; CREATE TABLE t1 (b INT) PARTITION BY RANGE ( b ) ( PARTITION p0 VALUES LESS THAN (10) DATA DIRECTORY = 'Query OK, 0 rows affected (0.02 sec) mysql> mysql> use db2; Database changed mysql> drop table if exists t1; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> CREATE TABLE t1 (b INT) PARTITION BY RANGE ( b ) -> ( PARTITION p0 VALUES LESS THAN (10) DATA DIRECTORY = '/home/openxs/dbs/5.1/var/db1/', -> PARTITION p1 VALUES LESS THAN (20) -> ); ERROR 1 (HY000): Can't create/write to file '/home/openxs/dbs/5.1/var/db1/t1#P#p0.MYD' (Errcode: 17) mysql> show tables; Empty set (0.01 sec) mysql> desc t1; ERROR 1146 (42S02): Table 'db2.t1' doesn't exist mysql> drop table t1; ERROR 1051 (42S02): Unknown table 't1' What I did wrong above? Maybe, I have to check non-debug build...
[24 Jun 2007 14:38]
MySQL Verification Team
stack does trace look like the bug I reported, bug #28490
[24 Jun 2007 18:29]
Martin Friebe
I agree with Shane, the "drop table" is probably the same as bug #28490. The problem is a not fully created table. The error with not cleaning up the table, if creation fails, seams myisam related. (so the sql needs a "engine myisam" in both create statements). I was able to trace what happens in the source. Looking at the 2nd "create table" (in db2, the one that is not cleaned): The error msg is createt in mysys/my_symlink2.c function my_create_with_symlink line 59: if (!access(filename,F_OK)) { my_error(EE_CANTCREATEFILE, MYF(0), filename, EEXIST); DBUG_RETURN(-1); } Note: this does NOT set "my_errno" my_create_with_symlink was called from storage/myisam/mi_create_c function mi_create line 694: if ((dfile= my_create_with_symlink(linkname_ptr, filename, 0, create_mode, MYF(MY_WME | create_flag))) < 0) goto err; .... line 834 err: pthread_mutex_unlock(&THR_LOCK_myisam); save_errno=my_errno; .... DBUG_RETURN(my_errno=save_errno); /* return the fatal errno */ So mi_create returns 0 / no error. This is passed on (as success) ha_myisam.cc ha_myisam::create() ha_partition.cc ha_partition::del_ren_cre_table() and in sql/ha_partition.cc ha_partition::create line 556 if (del_ren_cre_table(t_name, NULL, table_arg, create_info)) { handler::delete_table(t_name); DBUG_RETURN(1); } the "if" receives 0 (zero) from the call, and does not call handler::delete_table. However, if you manage to get such an unfinished table, it may be that fixing the above, will only make the crash happen earlier. Since the crash in "drop table" also happens in handler::delete_table. --- Outside of the above bug my_create_with_symlink is also called in storage/myisam/mi_create_c function mi_create line 639: if ((file= my_create_with_symlink(linkname_ptr, filename, 0, create_mode, MYF(MY_WME | create_flag))) < 0) goto err; Since it is in the same method, it is probably experiencing the same issue.
[27 Jun 2007 23:23]
Sveta Smirnova
Thank you for the report. Verified as described using last BK sources. Bug is repeatable only on FreeBSD. Linux and Mac versions are not affected.
[6 Jul 2007 10:30]
Georgi Kodinov
Tried with the latest 5.1bk (5.1.21beta). The server don't crash on Linux (Fedora7), FreeBSD 6 32bit (the box where sveta reproduced the effect with 5.1.19) and 64 bit. I got: + create database db1; + create database db2; + use db1; + drop table if exists t1; + Warnings: + Note 1051 Unknown table 't1' + CREATE TABLE t1 (a INT) PARTITION BY RANGE ( a ) + ( PARTITION p0 VALUES LESS THAN (10) , + PARTITION p1 VALUES LESS THAN (20) + ); + use db2; + drop table if exists t1; + Warnings: + Note 1051 Unknown table 't1' + CREATE TABLE t1 (b INT) PARTITION BY RANGE ( b ) ( PARTITION p0 VALUES LESS THAN (10) DATA DIRECTORY = '/usr/home/mysqldev/gkodinov/mysql-5.1.21-beta-pb267/mysql-test/var/master-data/db1/', PARTITION p1 VALUES LESS THAN (20) ); + ERROR HY000: Can't create/write to file '/usr/home/mysqldev/gkodinov/mysql-5.1.21-beta-pb267/mysql-test/var/master-data/db1/t1#P#p0.MYD' (Errcode: 17) + show tables; + Tables_in_db2 + desc t1; + ERROR 42S02: Table 'db2.t1' doesn't exist + drop table t1; + ERROR 42S02: Unknown table 't1' + use db2; + drop table t1; + ERROR 42S02: Unknown table 't1'