[MDEV-9155] Enabling Defragmenting in 10.1.8 still causes OPTIMIZE TABLE to take metadatalocks Created: 2015-11-19 Updated: 2017-04-17 Resolved: 2016-05-05 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB, Storage Engine - XtraDB |
| Affects Version/s: | 10.1.8 |
| Fix Version/s: | 10.1.14 |
| Type: | Bug | Priority: | Major |
| Reporter: | Kenny | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Environment: |
debian |
||
| Sprint: | 10.1.14 |
| Description |
|
Enabling Defragmenting in 10.1.8 still causes OPTIMIZE TABLE to take metadatalocks. enabled it:
this is how processlist looks like:
|
| Comments |
| Comment by Elena Stepanova [ 2015-11-19 ] | |||||||||||||||||||||||||
|
gryp, did you find anywhere in documentation that it should not be happening? Could you please paste the link for the reference? | |||||||||||||||||||||||||
| Comment by Kenny [ 2015-11-25 ] | |||||||||||||||||||||||||
|
The way the defragmentation is implemented is to reduce the impact on the database server. See: https://www.percona.com/live/mysql-conference-2014/sites/default/files/slides/defragmentation.pdf
Well, depends on how look at downtime. But the table is not accessible during the optimize table, so this means downtime for application usage.
index lock is released, why would it need to do that if the table has metadata locks? Because it's supposed to be online.
As a metadata locks is held, it has a very high overhead. So clearly this is not as it should be. | |||||||||||||||||||||||||
| Comment by Kenny [ 2015-11-25 ] | |||||||||||||||||||||||||
|
Next to what is mentioned in the slides mentioned in my previous comment, we can consider looking at some variables introduced by this feature:
Why declare a frequency? Because it's supposed to be running in the background and not interfere with the regular workload. | |||||||||||||||||||||||||
| Comment by Kenny [ 2015-11-25 ] | |||||||||||||||||||||||||
|
To give you another example, even a single select is blocked by the defragmentation:
| |||||||||||||||||||||||||
| Comment by Kenny [ 2015-11-25 ] | |||||||||||||||||||||||||
|
If MariaDB intended to implement this and set metadatalocks, I wonder what the real use case is here and maybe that should be updated in the documentation
| |||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2015-12-25 ] | |||||||||||||||||||||||||
|
Thanks. I don't know whether the Facebook presentation was overpromising, or whether it's MariaDB-specific changes that made the difference; assigning to jplindst to say which it is, and to fix if it requires fixing. | |||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2016-03-21 ] | |||||||||||||||||||||||||
|
Facebook implementation introduced new SQL-syntax and it used different metadata locks. MariaDB implementation re-used OPTIMIZE TABLE SQL-syntax and uses the metadata locks based on that. Not sure why it would take exclusive lock (replication ?) when shared should be enough to avoid concurrent DDL-operations. Assigning to serg for comment, can metadata lock be changed to shared-lock or no lock. | |||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2016-05-02 ] | |||||||||||||||||||||||||
|
This is a complex issue. OPTIMIZE always used to take rather strong locks because of MyISAM —MyISAM cannot allow any other connection accessing the table that is being optimized. InnoDB does not have this limitation. But we need to open the table to know whether it's MyISAM or InnoDB table. And we need to take metadata locks before the table is opened (because the table's engine is also part of metadata, we cannot read it without the metadata lock). We'll fix it nevertheless. But may be this fix won't make it into 10.1.14 | |||||||||||||||||||||||||
| Comment by Samuel Williams [ 2017-04-11 ] | |||||||||||||||||||||||||
|
I see that this issue appears to be closed, but I just tried innodb_fragment = 1 and optimise table still blocks access to that table. First, on connection #1:
Then, on connection #2:
It's blocked.
Is this to be expected?
| |||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-04-17 ] | |||||||||||||||||||||||||
|
ioquatix, it's a different issue. This | |||||||||||||||||||||||||
| Comment by Samuel Williams [ 2017-04-17 ] | |||||||||||||||||||||||||
|
Okay, do you know if there is an issue being tracked somewhere? Additionally, I tried using this, but no disk space was freed up despite there being I think 5Gb of unused space by the table - I dropped all indexes, etc. |