This patch tries to avoid some consistency problems related to InnoDB persistent statistics. It is a long story, but the persistent statistics are being written by an InnoDB internal SQL interpreter that requires the InnoDB data dictionary cache to be locked.
Before the above change, the statistics were written during DDL in separate transactions, which could unnecessarily reduce performance (each commit would require a redo log flush) and break atomicity, because the statistics would be updated separately from the dictionary transaction.
However, because it is unacceptable to hold the data dictionary cache locked while suspending the execution for waiting for a record lock (in the mysql.innodb_index_stats or mysql.innodb_table_stats tables) to be released, any lock conflict will immediately be reported as "lock wait timeout".
As far as I understand, such failures to update statistics did occur earlier as well, but maybe less frequently, because we would really suspend the thread while holding the dictionary lock. It is not the end of the world if the statistics are missing or a bit off. As a matter of fact, I noticed
a change in MySQL 5.7.11 (and MariaDB 10.2) that will purposely drop the statistics in a certain case of ALTER TABLE, and rely on a subsequent ha_innobase::open() to update them. It could actually make sense to do this on all ALTER TABLE operations. If we did this, then we would also rename tables in the statistics tables less often (only on RENAME TABLE), and would be less prone to get these errors. I do not think that it makes sense to ever update or rename statistics for the #sql table names.
I think that the likelihood of the problem is increased by executing multiple ALTER TABLE statements in parallel. It also "helps" to use partitioning.
So, in summary, MariaDB 10.2.12 should not be more broken than it was before, and I would like you to submit an issue at
https://jira.mariadb.org/ so that this can be fixed in an upcoming release.
On Tue, Jan 9, 2018 at 3:00 PM, Conor Murphy <conor_mark_murphy@hotmail.com> wrote: