A side effect of the
MDEV-24589 bug fix is that a scenario like the following could freeze the data file in a state that is not accepted later:
A later ALTER TABLE t1 IMPORT TABLESPACE could fail with:
The reason for this would be that if purge had not been completed for the DROP INDEX operation, the data file would still contain index pages that are marked as allocated and belonging to the indexes that were dropped. This would trip a check in PageConverter::update_index_page().
We can tolerate this error and ignore the extraneous pages on import. The space that is allocated by them would never be freed.
To work around this error and ensure that all index pages will really be marked as free in the data file, one should wait for purge to complete between DROP INDEX and FLUSH TABLES…FOR EXPORT, for example by executing something like this (
Sorry, exporting and importing tablespaces is somewhat of a mess until MDEV-11658 is implemented. That task would require file format changes (storing the secondary index root page numbers inside the .ibd file) as well as make the export wait for the purge of history to complete.
We will work around this error by making IMPORT TABLESPACE tolerate such garbage pages. Warnings will be issued for each orphaned page: