Bug #51449 Deadlock between INSERT and ALTER TABLE ... MODIFY ... CHARACTER SET
Submitted: 24 Feb 2010 8:19 Modified: 1 Mar 2010 14:01
Reporter: Elena Stepanova Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Locking Severity:S2 (Serious)
Version:Celosia (M3) OS:Windows
Assigned to: CPU Architecture:Any

[24 Feb 2010 8:19] Elena Stepanova
Description:
Table:

CREATE TABLE systest.tbstr (f1 char(255),
f2 varchar(1024),
f3 binary(255),
f4 varbinary(1024),
f5 blob,
f6 text) ENGINE = innodb;

Two threads run simple transactional DML flow:

USE systest;
set autocommit=0;
insert into tbstr (f1) values ('inserted');
commit;

Two other threads run ALTER TABLE:

USE systest;
let $CHSET2=`select character_set_name FROM information_schema.character_sets ORDER BY RAND() LIMIT 1`;
eval ALTER TABLE tbstr MODIFY f2 VARCHAR(1024) CHARACTER SET $CHSET2;

After a short while, all 4 threads stop.

Reproducible on Windows 2003, 2008. 
Could not reproduce on Linux.

Could not reproduce on 5.5.2-m2 (Betony).

How to repeat:
- unpack the attached archive in <mysql-basedir>/mysql-test. It should create
'stress_test_basedir' folder;
- on Linux/Solaris, run as  
perl ./stress_test_basedir/run.pl
- on Windows, run as  
perl stress_test_basedir\run_win.pl

Notes:
run[_win].pl is a wrapper for MTR to start server, and mysql-stress-test to run a 4-thread stress test. 
For mysql-stress-test you need to have perl with threads on the top of your path (or please modify run[_win].pl to call mysql-stress-test.pl with the right perl).

The screen output should say 'Waiting for server(s) to exit...' for a few seconds (sleep time for the server to start), and then start rapidly producing lines like

test_loop[0:0 0:26]: TID 2 test: 'stress2'  Errors: No Errors. Test Passed OK
test_loop[0:0 0:27]: TID 1 test: 'stress1'  Errors: No Errors. Test Passed OK

When/if the problem is hit, the output stops. 
 
If the server does not start fast enough, the test might report something like 

test_loop[0:0 0:2]: TID 2 test: 'stress1'  Errors: Severity S1

In this case please increase sleep time in run[_win].pl.

A path to MySQL client is hard-coded inside run.pl as ../bin/mysqltest 
and inside run_win.pl as ..\client\RelWithDebInfo\mysqltest. 
If it's different from yours, please modify it accordingly.
[24 Feb 2010 8:21] Elena Stepanova
mysql-stress-test-based test

Attachment: 51449_stress_test_basedir.zip (application/zip, text), 5.55 KiB.

[24 Feb 2010 8:25] Jon Olav Hauglid
Could this be a duplicate of Bug#51105 ?
[1 Mar 2010 14:01] Elena Stepanova
Confirmed: with the provided test case, not reproducible on mysql-next-4284 after the bugfix for #51105 (and reproducible on a build before the bugfix). 
Setting this bug to duplicate of #51105.