[MDEV-23670] Crash during OPTIMIZE TABLE mysql.innodb_table_stats Created: 2020-09-04 Updated: 2021-11-23 Resolved: 2021-09-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table, Storage Engine - InnoDB |
| Affects Version/s: | 10.0, 10.1.34, 10.3.23, 10.4.17, 10.2, 10.5 |
| Fix Version/s: | 10.6.5 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Joris de Leeuw | Assignee: | Marko Mäkelä |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | crash, optimizer, race | ||
| Environment: |
OS: CloudLinux like RHEL - Kernel: 3.10.0-962.3.2.lve1.5.32.el6h.x86_64 |
||
| Attachments: |
|
||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||
| Description |
|
We run rather large production servers with over hundreds of databases with varying sizes between a few MB and many GB. To improve performance we optimize tables periodically with a cron running this command:
We started noticing problems with crashing MariaDB servers during the optimize using MariaDB 10.1. We already switched to MariaDB 10.3 in the meantime. The problem keeps returning almost every optimize with MariaDB 10.3 on our most busy production servers. On less busy servers the problem seems more rare. In a test environments we are unable to reproduce the issue. Log:
Config:
|
| Comments |
| Comment by Joris de Leeuw [ 2020-12-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We still see the same behaviour with MariaDB 10.4.17. We hoped upgrading resolved this issue. It doesn't however happens every time that MariaDB crashes during an optimize, but seem to still happen more often on our more busy production servers. On our test environments we don't see this behaviour.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Joris de Leeuw [ 2021-02-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We still see sporadically MySQL crashes during a long running optimize on our production servers.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-02-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Does this only happen on the tables mysql.innodb_table_stats or mysql.innodb_index_stats? Those are a little special, and executing DDL (such as OPTIMIZE) on them is risky. If the problem occurs or other tables, then I would be interested to know more. For the statistics tables, this is not really a surprise to me. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Joris de Leeuw [ 2021-02-26 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
All crashes in the last few months on our production servers always seem to happen due to optimize on the 'innodb_index_stats' table and in some cases on the 'innodb_table_stats' table. We will exclude them in our optimize to see if this mitigates the problem. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-03-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Has excluding system tables from optimization process helped? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Joris de Leeuw [ 2021-03-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes. excluding the mysql databases in the optimize helps. We didn't see any crashes any more. We now use the following command:
So it is wise to skip the mysql database by default. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Valerii Kravchuk [ 2021-06-01 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We have yet another case of a similar stack trace and crash on OPTIMIZE (normal table, not anyone inside mysql database):
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-07-23 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I would need a stack trace of all threads during the crash, to analyze this. Please try to preserve the core dump for further questions (I may need to run some debugger commands to extract more information). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-09-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Joriz, I believe that running any DDL on the InnoDB statistics tables always was crash-prone before the fix of valerii, does the table of the support customer contain FULLTEXT INDEX? If yes, that could be a duplicate of | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-09-17 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Joriz, I believe that the originally reported issue (crash during OPTIMIZE TABLE mysql.innodb_index_stats or OPTIMIZE TABLE mysql.innodb_table_stats) has been fixed in In older release series this bug is not feasible to fix, because that fix depends on many large refactoring tasks that were only implemented in the 10.6 release series. The crash that a support customer reported for 10.1.34 may or may not have occurred due to the same reason. There is no such assertion expression table->get_ref_count() == 0 in the 10.1 source code. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jan Ingvoldstad [ 2021-11-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This issue also appears to apply to MariaDB 10.5.13. After rebooting a Debian system with 10.5.13, crashed tables are automatically attempted repaired, and this results in crashes a few times per minute with the following error: InnoDB: Assertion failure in file /home/buildbot/buildbot/build/mariadb-10.5.13/storage/innobase/row/row0merge.cc line 4338 After upgrading to MariaDB 10.6.5, it appears stable, repairing tables does not crash the server. It would therefore be nice if 10.5.13 was added to the list of affected versions where this crasher will not be fixed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-11-23 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I do not think that it is feasible to port the fix ( |