[MDEV-21549] IMPORT TABLESPACE fails to adjust all tablespace ID in root pages Created: 2020-01-21 Updated: 2020-05-06 Resolved: 2020-03-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB, Storage Engine - XtraDB |
| Affects Version/s: | 10.0, 10.1, 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.1.45, 10.2.32, 10.3.23, 10.4.13, 10.5.3 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | affects-tests, crash | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
I happened to get this crash today once on a 10.5-based branch.
The following code was added to ha_innobase::discard_or_import_tablespace() in
I believe that the check called by btr_cur_instant_init_low() must be relaxed. It is a hard assertion, affecting non-debug builds as well, because UNIV_BTR_DEBUG is always enabled. That is why I am setting this to Critical. We should not crash, but return a failure to the caller of btr_cur_instant_init_low(). This may require specializing the btr_root_get() call. Furthermore, when opening the table during IMPORT TABLESPACE, we must either suppress the tablespace ID validation, or we should temporarily set table->space_id to the ID that is present in the tablespace file. Last but not least, during IMPORT TABLESPACE, the call to btr_cur_instant_init_low() must not fetch an older page from the buffer pool (it might be there after DISCARD TABLESPACE), but actually read the page from the file. See also the related 10.4+ bug |
| Comments |
| Comment by Marko Mäkelä [ 2020-01-21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
One explanation why the test crashes so rarely could be ‘stale’ pages left in the buffer pool after DISCARD TABLESPACE by | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-03-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I am taking over this, because the test innodb_zip.wl5522_debug_zip fails on 10.5 kvm-asan due to this every time. I was not able to repeat the failure on a clone of the VM image, but I was able to repeat a failure of innodb.innodb-wl5522-debug locally again. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-03-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
It looks like ALTER TABLE…IMPORT TABLESPACE was always broken in this way. PageConverter::update_index_page() always failed to update all 3 copies of tablespace identifier in the index root pages. InnoDB generally ignored the wasted 4+4 bytes (which are not wasted only in B-tree root pages, but in each B-tree page header!) in BTR_SEG_TOP and BTR_SEG_LEAF. I was able to rather reliably repeat the error with the following test case:
It would typically fail on the first or second round. It is unclear why this started to fail just now. Maybe The consistency check was originally added along with the function btr_root_block_get() probably by me in Oracle’s InnoDB Plugin for MySQL 5.1. With the following fix, the crash goes away:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-03-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I pushed the fix to 10.5, to get a clean kvm-asan for the 10.5.2 release, without having to wait for several days for a merge from 10.2. While chasing this down, I worked on cleaning up the IMPORT tests. I plan to push that cleanup along with the fix to the 10.2 branch. I will close the bug once that is done. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-03-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I spent some additional effort to clean up the import/export tests, hoping to make them run slightly faster. |