[MDEV-9459] Truncate table causes innodb stalls Created: 2016-01-24 Updated: 2021-09-30 Resolved: 2018-09-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Fix Version/s: | 10.3.10, 10.2.19 |
| Type: | Task | Priority: | Critical |
| Reporter: | MG | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 4 |
| Labels: | upstream-fixed | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||
| Description |
|
Feature request: Backport the MySQL 5.8 fix for upstream bug https://bugs.mysql.com/bug.php?id=68184 for MariaDB 10.2 This performance issue seems more pronounced with Galera Cluster feature enabled using TOI but also affects standalone instances (admittedly I have seen this in the 10.0 series but have not tested 10.1 for this problem directly) |
| Comments |
| Comment by Elena Stepanova [ 2016-02-21 ] | ||
|
axel, jplindst, do you know if 10.1 is affected by this issue? | ||
| Comment by Jan Lindström (Inactive) [ 2016-02-22 ] | ||
|
Yes it is, but MySQL 5.8.0 is not yet released so back port is not yet possible. Furthermore, as one can see from developer comments there is no known working solution for 5.6 based MySQL. | ||
| Comment by Elena Stepanova [ 2016-02-22 ] | ||
|
Apparently, despite the comment by Vasil Dimov, the change didn't make it to 5.7 after all, and it will be impossible to backport the fix to 5.7-based MySQL, too? Anyway, I'm setting it to confirmed according to Jan's comment above, and for now I'll set the fix version to 10.2 so it stays on the radar. If 5.8 InnoDB won't make it to 10.2, which most likely will be the case, then the fix version will be updated to a later release. | ||
| Comment by MG [ 2016-11-20 ] | ||
|
Upstream 8.0.0-dmr has changed fil_prepare_for_truncate and fil_truncate_tablespace in ./storage/innobase/fil/fil0fil.cc I believe to address this | ||
| Comment by Marko Mäkelä [ 2016-11-23 ] | ||
|
There are two recent changes to TRUNCATE TABLE in MySQL. When it comes to stalls, InnoDB fixed stalls for DROP TABLE quite some time ago. The WL#6501 TRUNCATE TABLE in MySQL 5.7 is holding dict_sys->mutex and dict_operation_lock while performing time-consuming tasks, such as dropping any adaptive hash index entries (pointers from buf_block_t::index to to-be-dropped dict_index_t). | ||
| Comment by Jan Lindström (Inactive) [ 2017-03-22 ] | ||
|
While we definitely would like to have atomic truncate with ho stalls, I do not see that feasible on 10.2 with current deadlines. We have plans for own own global DD, thus moving this to 10.4 for now. | ||
| Comment by Marko Mäkelä [ 2017-11-30 ] | ||
|
As I noted in It is possible that some bottleneck related to redo log checkpoint will remain until the crash recovery of TRUNCATE operations has been rewritten to rely on an undo log record. Such a change would necessarily be part of | ||
| Comment by Marko Mäkelä [ 2017-12-01 ] | ||
|
I now realize that the original request was filed against MySQL 5.5. The original request was that in TRUNCATE, InnoDB should release the file space while not holding any lock. To do that, we must change the undo or redo logging, so that we can ensure that no orphan files will be left behind in case the server is killed after the TRUNCATE transaction internally commits. A similar problem exists in DROP TABLE. It would be better to release all locks and only after that start deleting the file. This would improve the performance for dropping large or heavily fragmented tables. We might be able to fix this in MariaDB 10.3. I believe that in MySQL 5.7 (and in MariaDB 10.2.2 and 10.3), the performance of TRUNCATE degraded in some scenarios. Because the crash recovery of TRUNCATE uses separate log files, a redo log checkpoint will be part of the TRUNCATE execution. This could force all dirty pages to be written out from the buffer pool to the data files. I am afraid that we cannot fix this problem before MariaDB 10.4. | ||
| Comment by Marko Mäkelä [ 2017-12-01 ] | ||
|
The WL#7016 that I mentioned in my earlier comment (and in some MySQL 8.0 née 5.8 commit messages) will likely remain private forever. Its contents was copied to another number, WL#9536 which has been slightly modified. At the time I fixed WL#6795 in the development version of MySQL (called 5.8 at that time), the crash recovery part was not yet implemented. MySQL 8.0.3 was the first version to implement it.
The caller does not appear to hold any global locks at this point. This operation does not look completely transactional or crash-safe, because row_drop_table_for_mysql_in_background() was not removed. But, the file deletion in fact does seem to be executed in the innobase_post_ddl() function, apparently after all locks have been released in Sql_cmd_truncate_table::truncate_table(). This corresponds to what I designed in WL#7016 and what was copied to WL#9536. MariaDB cannot port the change from MySQL 8.0, because the solution depends on the Global Data Dictionary, which MariaDB will not implement in that form. | ||
| Comment by Marko Mäkelä [ 2018-09-21 ] | ||
|
This was fixed as part of | ||
| Comment by Marko Mäkelä [ 2018-11-01 ] | ||
|
A remaining major cause of stalls would be addressed in |