Bug #54602 InnoDB acquires table read lock during analyze table
Submitted: 18 Jun 2010 1:50 Modified: 22 Jun 2010 18:48
Reporter: Mikiya Okuno Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[18 Jun 2010 1:50] Mikiya Okuno
Description:
http://dev.mysql.com/doc/refman/5.1/en/analyze-table.html

This page says " During the analysis, the table is locked with a read lock for MyISAM. For InnoDB the table is locked with a write lock. This statement works with MyISAM and InnoDB tables." However, actually ANALYZE TABLE can proceed when another session locks the table with READ LOCK.

How to repeat:
mysql1> LOCK TABLE t1 READ;

mysql2> ANALYZE TABLE t1;

=====> The command completes without releasing the lock.

mysql1> LOCK TABLE t1 WRITE;

mysql2> ANALYZE TABLE t1;

=====> The command is blocked until the lock is released.

So, actually READ LOCK is required for ANALYZE TABLE for InnoDB.

Suggested fix:
Please fix the document.
[22 Jun 2010 18:48] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.