[MDEV-25854] Restoring a backup may result in garbage intermediate tables from DDL Created: 2021-06-04 Updated: 2022-01-28 Resolved: 2021-06-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | mariabackup, Storage Engine - InnoDB |
| Affects Version/s: | 10.6.1 |
| Fix Version/s: | 10.6.2 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | regression | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||
| Description |
|
Specifically, the command mariabackup --prepare --export is supposed to purge the history of old transactions, and also apply all logs. Starting with The following patch proves that a regression was introduced. If the function (which would start the InnoDB purge of transaction history) would be invoked during mariabackup --prepare --export, the execution would be aborted due to assertion failure.
We must ensure that ha_signal_ddl_recovery_done() will be invoked. Should it for some reason be unacceptable to invoke ddl_log_execute_recovery() in mariabackup --prepare --export, then we would have to invoke special code that would drop all #sql- tables from InnoDB, before executing ha_signal_ddl_recovery_done(). In any case, we must somehow compensate for the change that was made in Note: Nothing must change in mariabackup outside --prepare --export. We do not want to ruin incremental backups by executing actions that would generate InnoDB redo log records. |
| Comments |
| Comment by Marko Mäkelä [ 2021-06-04 ] |
|
I think that a long term goal should be to remove the need to run mariabackup --prepare, that is, to allow the normal server recovery to work on files generated by mariabackup --backup. There could be some special server options to automatically shut down after running steps that were part of mariabackup --prepare. |
| Comment by Michael Widenius [ 2021-06-08 ] |
|
In 10.6 we have a log of all ddl's (ddl.log). It would be trivia to add all #sql- tables created to it in ALTER TABLE.
I have verified with Marko that it should work (or should be trivial to achieve) that we can drop InnoDB tables even if the .idb file does not exists (which means we don't have to copy the #sql- files) |
| Comment by Marko Mäkelä [ 2021-06-11 ] |
|
I think that files with names #sql-ib*.ibd must always be copied. After Furthermore, if we choose not to copy other #sql-*.ibd files, I do not think that incremental backups can work. If my understanding is correct, incremental backup could work if we always backed up the latest ddl_recovery.log, and on mariabackup --prepare never applied that log. The only exceptions should be partial backups (which may choose to omit any files) and mariabackup --prepare --export (which I think needs to apply the ddl_recovery.log). Normally, after restoring a backup, the ddl_recovery.log should be applied by server startup. Note: I do not know how exactly backup locks work, and I now realize that if the effects of invoking purge_sys.resume_SYS() become visible in backup, then the |
| Comment by Marko Mäkelä [ 2021-06-16 ] |
|
wlad, I am assigning this to you because you are working on a solution. The current solution would be roughly as follows:
|