Due to a data corruption bug in the past (such as MySQL Bug #69122 InnoDB doesn't redo-log insert buffer merge operation if it is done in-place) it seems possible that the InnoDB change buffer ends up containing entries, while no buffered changes exist according to the change buffer bitmap pages in the .ibd files.
The logic on slow shutdown would proceed as follows:
- ibuf_merge_pages() calls btr_pcur_open_at_rnd_pos(), which will find a change buffer leaf page
- page numbers are read from the change buffer records
- page reads requests will be posted
- on read completion, ibuf_merge_or_delete_for_page() will be invoked
- Alas, the bitmap page in the .ibd says that there are no buffered changes, and nothing will be done.
- Because the ‘orphan’ records for the page were not deleted from the change buffer, this will keep looping.
To fix this, I think that we should change the following code in ibuf_merge_or_delete_for_page():
Before returning, we should check if slow shutdown is in progress. If yes, we should attempt to delete any change buffer entries for page_id. We should not try this during normal operation, because it would cause a lot of unnecessary work.