Bug #27408 Alter table ADD partition .... with Data Directory causes MySql Server to crash
Submitted: 23 Mar 2007 19:28 Modified: 16 Oct 2007 16:42
Reporter: Yuriy Maksimov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Partitions Severity:S1 (Critical)
Version:5.1.16/5.1BK OS:Microsoft Windows (MS Windows Server 2003)
Assigned to: Alexey Botchkov CPU Architecture:Any

[23 Mar 2007 19:28] Yuriy Maksimov
Description:
Adding a new partition to the table with PARTITION BY LIST crashes the server if DATA and INDEX DIRECTORY options are used.

-- Here is the table definition: 

CREATE TABLE `t2` ( 
`col1` int(11) DEFAULT NULL 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 
PARTITION BY LIST ( col1) 
(partition p1 values in (null)); 

-- then I try to add a new partition - this works fine 

alter table t2 
add partition 
(partition p2 values in (1)); 

show create table t2; 

-- CREATE TABLE `t2` ( 
-- `col1` int(11) DEFAULT NULL 
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 
 /*!50100 PARTITION BY LIST ( col1) 
 (PARTITION p1 VALUES IN (NULL) ENGINE = InnoDB, 
 PARTITION p2 VALUES IN (1) ENGINE = InnoDB) */ 

-- then try to add another partition with DATA and INDEX DIRECTORY - this one   
-- crashes MySql server. 

alter table t2 
add partition 
(partition p3 values in (2) 
data directory = 'C:\TestDB' 
index directory = 'C:\TestDB' 
); 

-- Those folder exists, my account has all possible rights, MySql 5.1.16 on
-- Windows server 2003, MySql runs as a service, Engine=InnoDB. 

How to repeat:
Execute the code above.
[24 Mar 2007 0:28] Miguel Solorzano
Thank you for the bug report. I was only able to repeat with Windows
version with current source tree.

c:\mysql-5.1.16-beta-win32>bin\mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.16-beta-community-nt MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE TABLE `t2` (
    -> `col1` int(11) DEFAULT NULL
    -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8
    -> PARTITION BY LIST ( col1)
    -> (partition p1 values in (null));
Query OK, 0 rows affected (0.08 sec)

mysql> alter table t2
    -> add partition
    -> (partition p2 values in (1));
Query OK, 0 rows affected (0.52 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table t2
    -> add partition
    -> (partition p3 values in (2)
    -> data directory = 'C:\TestDB'
    -> index directory = 'C:\TestDB'
    -> );
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>
--------------------------------------------------------------
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.18-beta-nt Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database db7;
Query OK, 1 row affected (0.01 sec)

mysql> use db7
Database changed
mysql> CREATE TABLE `t2` (
    -> `col1` int(11) DEFAULT NULL
    -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8
    -> PARTITION BY LIST ( col1)
    -> (partition p1 values in (null));
Query OK, 0 rows affected (0.30 sec)

mysql>
mysql> alter table t2
    -> add partition
    -> (partition p2 values in (1));
Query OK, 0 rows affected (0.58 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table t2
    -> add partition
    -> (partition p3 values in (2)
    -> data directory = 'C:\TestDB'
    -> index directory = 'C:\TestDB'
    -> );
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>

>	mysqld-nt.exe!append_file_to_dir(THD * thd=0x02b36bc0, const char * * filename_ptr=0x02b89504, const char * table_name=0x00000001)  Line 6292 + 0x18 bytes	C++
 	mysqld-nt.exe!ha_partition::set_up_table_before_create(st_table * table=0x02b7c718, const char * partition_name_with_path=0x0a81d398, st_ha_create_information * info=0x02b892c0, unsigned int part_id=0, partition_element * part_elem=0x02b894c8)  Line 1792 + 0x18 bytes	C++
 	mysqld-nt.exe!ha_partition::prepare_new_partition(st_table * table=0x02b7c718, st_ha_create_information * create_info=0x02b892c0, handler * file=0x02b89818, const char * part_name=0x0a81d398, partition_element * p_elem=0x02b894c8)  Line 1137 + 0x23 bytes	C++
 	mysqld-nt.exe!ha_partition::change_partitions(st_ha_create_information * create_info=0x02b892c0, const char * path=0x0a81d5c0, unsigned __int64 * copied=0x0a81d9bc, unsigned __int64 * deleted=0x0a81d9c4, const void * pack_frm_data=0x00000000, unsigned int pack_frm_len=0)  Line 1456 + 0x22 bytes	C++
 	mysqld-nt.exe!mysql_change_partitions(st_lock_param_type * lpt=0x00000000)  Line 5058 + 0x37 bytes	C++
 	mysqld-nt.exe!fast_alter_partition_table(THD * thd=0x02b36bc0, st_table * table=0x02b7c718, st_alter_info * alter_info=0x02b38188, st_ha_create_information * create_info=0x02b892c0, st_table_list * table_list=0x02b88e38, List<create_field> * create_list=0x0a81dad4, List<Key> * key_list=0x0a81db18, char * db=0x02b89008, const char * table_name=0x02b88e10, unsigned int fast_alter_partition=1)  Line 6276 + 0x29 bytes	C++
 	mysqld-nt.exe!mysql_alter_table(THD * thd=0x02b36bc0, char * new_db=0x02b89008, char * new_name=0x00000000, st_ha_create_information * lex_create_info=0x02b37fb0, st_table_list * table_list=0x02b88e38, List<create_field> & fields={...}, List<Key> & keys={...}, unsigned int order_num=0, st_order * order=0x00000000, int ignore=0, st_alter_info * alter_info=0x02b38188, int do_send_ok=1)  Line 6161 + 0x35 bytes	C++
 	mysqld-nt.exe!mysql_execute_command(THD * thd=0x02b36bc0)  Line 2356 + 0x52 bytes	C++
 	mysqld-nt.exe!mysql_parse(THD * thd=0x02b36bc0, char * inBuf=0x02b88d58, unsigned int length=122)  Line 5232	C++
 	mysqld-nt.exe!dispatch_command(enum_server_command command=COM_QUERY, THD * thd=0x02b36bc0, char * packet=0x02b80d29, unsigned int packet_length=123)  Line 898	C++
 	mysqld-nt.exe!do_command(THD * thd=0x0000007b)  Line 662 + 0x10 bytes	C++
 	mysqld-nt.exe!handle_one_connection(void * arg=0x02b36bc0)  Line 1089 + 0xa bytes	C++
 	mysqld-nt.exe!_pthread_start()  + 0x3b bytes	C
 	mysqld-nt.exe!_callthreadstart()  Line 293 + 0x6 bytes	C
 	6332e900()
[29 Mar 2007 13:12] Alexey Botchkov
It's another form of the #26074
http://bugs.mysql.com/bug.php?id=26074
[29 Mar 2007 13:14] Alexey Botchkov
still initial testcase should be checked when 26074 is pushed
[16 Oct 2007 16:42] Miguel Solorzano
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

c:\dev\5.1>bin\mysql -uroot db7
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.23-beta-nt Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE TABLE `t2` (
    ->  `col1` int(11) DEFAULT NULL
    ->  ) ENGINE=InnoDB DEFAULT CHARSET=utf8
    ->  PARTITION BY LIST ( col1)
    ->  (partition p1 values in (null));
Query OK, 0 rows affected (0.21 sec)

mysql>
mysql>
mysql> alter table t2
    -> add partition
    -> (partition p2 values in (1));
Query OK, 0 rows affected (0.94 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql>
mysql>
mysql> alter table t2
    -> add partition
    -> (partition p3 values in (2)
    -> data directory = 'C:\TestDB'
    ->  index directory = 'C:\TestDB'
    -> );
Query OK, 0 rows affected (0.58 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> show variables like "%version%";
+-------------------------+---------------------+
| Variable_name           | Value               |
+-------------------------+---------------------+
| protocol_version        | 10                  |
| version                 | 5.1.23-beta-nt      |
| version_comment         | Source distribution |
| version_compile_machine | unknown             |
| version_compile_os      | Win64               |
+-------------------------+---------------------+
5 rows in set (0.00 sec)

mysql>