MDEV-24569: Change buffer merge modifies freed page
Starting with MDEV-15528, we will avoid writing freed pages back to data files. During stress testing, the assertion mach_read_from_4(frame + 4U) == block.page.id().page_no() failed in log_phys_t::apply(), because before the server was killed and restarted, change buffer merge was executed on a previously freed page. During recovery, the assertion would fail when InnoDB would apply a FREE_PAGE and a WRITE record to the page. ibuf_merge_or_delete_for_page(): Before applying any changes, check whether the secondary index leaf page has already been freed according to the allocation bitmap page. If it is freed, then we must reset the bits in change buffer bitmap page. ibuf_reset_bitmap(): Auxiliary function for repeated code. mtr_t::sx_lock_space(): Replaces mtr_t::x_lock_space(). Due to the lazy approach of the change buffer, The function ibuf_merge_or_delete_for_page() may be executed in buf_page_create() while the tablespace is already X-latched. An S-latch must not be acquired while the thread already holds an X-latch, but a redundant SX-latch is fine. The fix was developed by Thirunarayanan Balathandayuthapani.
Showing
Please register or sign in to comment