Bug #69030 | Optimize table locks whole database | ||
---|---|---|---|
Submitted: | 22 Apr 2013 12:55 | Modified: | 24 Apr 2013 11:23 |
Reporter: | Jens Rantil | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Locking | Severity: | S1 (Critical) |
Version: | 5.1.66 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | documentation, locking, opening tables, optimize table |
[22 Apr 2013 12:55]
Jens Rantil
[23 Apr 2013 16:33]
MySQL Verification Team
Hi ! MySQL 5.1 does not lock entire database when optimizing a single table within it. Regardless of whether it is MyISAM or InnoDB SE. There are two possible causes of what you see. Your other queries involved a table that was optimized, in which case they had to wait on locked table. Much more plausible explanation is that there was that relatively little space was left on disk and that a filesystem mounted on that partition was highly fragmented. In such a case and especially when I/O load is above 90 % , operating system becomes very slow in opening tables. Do not forget, also, that 5.1 has the bug that lock on the table is held during entire time that it takes to remove it from filesystem. This was fixed in 5.6. I have tried your case on a partition with over 500 Gb free and could access other tables without any problems.
[24 Apr 2013 11:23]
Jens Rantil
Sinisa, Thank you for taking your time to look into this. See answers inline below. > There are two possible causes of what you see. Your other queries involved a table that was optimized, in which case they had to wait on locked table. This was not the case. None of the blocked SELECTs touched the table that I was optimizing. > Much more plausible explanation is that there was that relatively little space was left on disk and that a filesystem mounted on that partition was highly fragmented. In such a case and especially when I/O load is above 90 % , operating system becomes very slow in opening tables. Do not forget, also, that 5.1 has the bug that lock on the table is held during entire time that it takes to remove it from filesystem. This was fixed in 5.6. Very well, it must have been the fragmented file system then. This might explain why I did not notice the blocked SELECTs on the master database. > I have tried your case on a partition with over 500 Gb free and could access other tables without any problems. Thank you for taking your time to look into this.
[24 Apr 2013 14:25]
MySQL Verification Team
For your own education do two more things. 1) Check whether queries on tables from other databases work or not ... do make sure that other databases are on the same partition / filesystem. 2) Create a database (manually) on some other (mostly with ample space) partition / filesystem and symlink it to datadir. Create some tables there and try running queries while you run OPTIMIZE on the table in your original database.