[MDEV-20939] Race condition between mysqldump import and InnoDB persistent statistics calculation Created: 2019-10-31 Updated: 2021-03-24 Resolved: 2021-01-27 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Backup, Scripts & Clients, Storage Engine - InnoDB |
| Affects Version/s: | 10.2.27, 10.1.41, 10.3.18, 10.4.8 |
| Fix Version/s: | 10.2.37, 10.3.28, 10.4.18, 10.5.9 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Rucha Deodhar |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
mysqldump ignores some internal tables by default, such as:
See here: https://github.com/MariaDB/server/blob/mariadb-10.4.8/client/mysqldump.c#L1001 I think the following tables should also be ignored by default:
The reason is that if someone tries to import a dump created by mysqldump, then a race condition between the import and the InnoDB persistent statistics calculation exists, and the user can see errors like this:
This was reported long ago in the following upstream bug report: https://bugs.mysql.com/bug.php?id=71814 The workaround mentioned in that bug report is to disable InnoDB persistent statistics prior to the import:
However, it would be more ideal to make this workaround unnecessary by fixing the problem. |
| Comments |
| Comment by Oleksandr Byelkin [ 2020-03-18 ] |
|
I am afraid we can not just ignore the tables: |
| Comment by Geoff Montee (Inactive) [ 2020-03-18 ] |
|
What if the schema of the tables were dumped, but the data was ignored? The data will be recalculated by InnoDB anyway, so it doesn't need to be dumped. |
| Comment by Oleksandr Byelkin [ 2020-03-19 ] |
|
yes, I am moving in this direction |
| Comment by Oleksandr Byelkin [ 2020-03-19 ] |
|
As a side effect there will be a new parameter --ignore-table-data and by default both tables will be in it |
| Comment by Oleksandr Byelkin [ 2020-03-19 ] |
|
commit 5514b48673ceeefc0427834df233e2e8e381f862 (HEAD For mysql.innodb_index_stats and mysql.innodb_table_stats by default --ignore-table-data parameter added. |
| Comment by Oleksandr Byelkin [ 2020-03-25 ] |
|
we decided to make workaround possible with new parameter in mysqldump for 10.1 and above, but this MDEV goes to innodb team for fix inside innodb |
| Comment by Marko Mäkelä [ 2020-07-16 ] |
|
I think that this bug could be fixed by using proper MDL protection for the InnoDB statistics tables. That we can achieve by replacing the interface that is writing to the tables. I am reassigning this bug to psergey so that he can provide the code that has been requested in |
| Comment by Sergei Golubchik [ 2020-12-12 ] |
|
That's too much of a refactoring to block such a simple issue. Let's just do what Geoff suggested and ignore the table like mysqldump already does for all other system tables. Or ignore only data, as |
| Comment by Rucha Deodhar [ 2021-01-21 ] |
|
(previous) Patch: https://github.com/MariaDB/server/commit/96d10fc1da963b78354a5f768c49d05035aaba60 Patch after Daniel Black suggested changes(final patch): |
| Comment by Sergei Golubchik [ 2021-01-21 ] |
|
See the second comment — if tables aren't even created, the log will have annoying errors. Let's dump the table structure, but not the data. Another consideration, should dump_all_stats() still dump innodb stat tables? danblack, what do you think? |
| Comment by Daniel Black [ 2021-01-22 ] |
|
With --insert-ignore (opt_ignore) or --replace (opt_replace_into) there isn't an issue with dumped sql. Because these innodb tables are meant to support a persistent stats (https://mariadb.com/kb/en/innodb-persistent-statistics/) I think it should be still possible to dump them with --system=stats (or a normal dump if --replace or --insert-ignore) is specified. In the proposal below I've changed the dump_all_stats, and dump_all_timezones (the two that use inserts directly), to use `REPLACE INTO` in the event --insert-ignore isn't specified in order to prevent PK/unique key conflicts. I've also changed to use the ignore_data table for the base case. bb-10.2-danielblack- updated commit, includes test. Also unsure why general_log/slow_log aren't excluded in test. Acceptable? TODO man/mysqldump.1 updates |
| Comment by Rucha Deodhar [ 2021-01-22 ] |
|
serg |
| Comment by Daniel Black [ 2021-01-23 ] |
|
Was there a reason the conditional on !(opt_ignore || opt_replace_into) wasn't acceptable? rucha174 on your patch.
Should be covered: man/mysqldump.1 update to reflect this change |
| Comment by Rucha Deodhar [ 2021-01-25 ] |
|
serg Also, danblack has pushed fix about dump_all_stats() and dump_all_timezones() to 10.2 related to this issue. |
| Comment by Sergei Golubchik [ 2021-01-27 ] |
|
96702de22923728b255293d4c38ab07a56deb782 is ok to push |