In stress testing, we got an assertion failure due to a call in ibuf_read_merge_pages():
The BUF_GET should actually be BUF_GET_POSSIBLY_FREED, and buf_page_get_gen() must not attempt to merge any buffered changes to freed pages. The scenario likely is something like this:
- INSERT, UPDATE or DELETE is written to the change buffer.
- DROP INDEX is executed and the page is freed, before the buffered changes are merged.
- Something else is written to the change buffer, and ibuf_insert_low() invokes ibuf_read_merge_pages() to merge (or remove) the entries for the page that was freed by DROP INDEX.
MDEV-21572 seems to have broken buf_page_get_gen() so that it will wrongly skip change buffer merge in a rare scenario that I did not verify:
- A secondary index leaf page is initialized and modified.
- The page is evicted.
- Something is buffered for the page.
- All the redo log was durably written, and no log_checkpoint() took place.
- The server is killed.
- On restart, we read the page, but fail to merge the buffered changes.
(It is highly unlikely that the page would be evicted while there would not be a log checkpoint between the page initialization, eviction, and the change buffer write.)