Commit 37e5ec9f authored by elliot@mysql.com's avatar elliot@mysql.com

Applying patch from SergeyV

Fixes bug#17264, for alter table on win32 for successfull operation completion
it is used TL_WRITE(=10) lock instead of TL_WRITE_ALLOW_READ(=6), however here
in innodb handler TL_WRTIE is lifted to TL_WRITE_ALLOW_WRITE, which causes
race condition when several clients do alter table simultaneously.
parent d0d32f7d
......@@ -67,3 +67,9 @@ Select_priv
N
use test;
use test;
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
lock tables t1 write;
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
unlock tables;
drop table t1;
......@@ -171,4 +171,30 @@ use test;
#
connection default;
#
# Bug #17264: MySQL Server freeze
#
connection locker;
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
lock tables t1 write;
connection writer;
--sleep 2
delimiter //;
send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
delimiter ;//
connection reader;
--sleep 2
delimiter //;
send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
delimiter ;//
connection locker;
--sleep 2
unlock tables;
connection writer;
reap;
connection reader;
reap;
connection locker;
drop table t1;
# End of 5.0 tests
......@@ -6684,6 +6684,17 @@ ha_innobase::store_lock(
&& !thd->tablespace_op
&& thd->lex->sql_command != SQLCOM_TRUNCATE
&& thd->lex->sql_command != SQLCOM_OPTIMIZE
#ifdef __WIN__
/*
for alter table on win32 for succesfull operation
completion it is used TL_WRITE(=10) lock instead of
TL_WRITE_ALLOW_READ(=6), however here in innodb handler
TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes
race condition when several clients do alter table
simultaneously (bug #17264). This fix avoids the problem.
*/
&& thd->lex->sql_command != SQLCOM_ALTER_TABLE
#endif
&& thd->lex->sql_command != SQLCOM_CREATE_TABLE) {
lock_type = TL_WRITE_ALLOW_WRITE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment