Description:
20 threads inserting and optimizing an archive table leads to a indefinate hangup and 100% cpu usage
mysql> show processlist;
+----+------+-----------+------+---------+------+--------------------------+---------------
| Id | User | Host | db | Command | Time | State | Info
+----+------+-----------+------+---------+------+--------------------------+---------------
| 18 | root | localhost | test | Query | 8 | freeing items | SHOW /*!50010
| 19 | root | localhost | test | Execute | 495 | Waiting for table | insert into t1
| 20 | root | localhost | test | Prepare | 490 | Opening tables | insert into t1
| 21 | root | localhost | test | Query | 495 | Waiting to get writelock | optimize table
| 22 | root | localhost | test | Execute | 495 | Opening tables | insert into t1
| 23 | root | localhost | test | Query | 495 | Opening tables | check table t1
| 24 | root | localhost | test | Query | 495 | Waiting for table | check table t1
| 25 | root | localhost | test | Prepare | 495 | Waiting for table | insert into t1
| 26 | root | localhost | test | Execute | 495 | Opening tables | insert into t1
| 27 | root | localhost | test | Execute | 490 | Opening tables | insert into t1
| 28 | root | localhost | test | Execute | 490 | Opening tables | insert into t1
| 29 | root | localhost | test | Execute | 495 | Opening tables | insert into t1
| 30 | root | localhost | test | Execute | 490 | Opening tables | insert into t1
| 31 | root | localhost | test | Query | 495 | Waiting to get writelock | optimize table
| 32 | root | localhost | test | Execute | 495 | Opening tables | insert into t1
| 33 | root | localhost | test | Execute | 490 | Opening tables | insert into t1
| 34 | root | localhost | test | Query | 490 | Waiting for table | checksum table
| 35 | root | localhost | test | Query | 495 | Opening tables | optimize table
| 36 | root | localhost | test | Execute | 490 | Opening tables | insert into t1
| 37 | root | localhost | test | Query | 495 | Waiting to get writelock | optimize table
| 38 | root | localhost | test | Execute | 495 | Waiting for table | insert into t1
| 41 | root | localhost | test | Query | 0 | NULL | show processli
+----+------+-----------+------+---------+------+--------------------------+---------------
How to repeat:
will make a testcase later.
Suggested fix:
.