[MDEV-22495] Assertion mode == 16 || mode == 12 || fix_block->page.status != buf_page_t::FREED failed in ibuf_read_merge_pages() Created: 2020-05-07  Updated: 2020-05-26  Resolved: 2020-05-08

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.5
Fix Version/s: 10.5.3

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: corruption, performance, recovery

Issue Links:
Problem/Incident
is caused by MDEV-15528 Avoid writing freed InnoDB pages Closed
Relates
relates to MDEV-22710 Assertion `mode == 16 || mode == 12 |... Closed

 Description   

In stress testing, we got an assertion failure due to a call in ibuf_read_merge_pages():

			buf_page_get_gen(page_id_t(space_id, page_nos[i]),
					 zip_size,
					 RW_X_LATCH, NULL, BUF_GET,
					 __FILE__, __LINE__, &mtr, &err, true);

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:

  1. INSERT, UPDATE or DELETE is written to the change buffer.
  2. DROP INDEX is executed and the page is freed, before the buffered changes are merged.
  3. 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.

Furthermore, 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:

  1. A secondary index leaf page is initialized and modified.
  2. The page is evicted.
  3. Something is buffered for the page.
  4. All the redo log was durably written, and no log_checkpoint() took place.
  5. The server is killed.
  6. 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.)


Generated at Thu Feb 08 09:15:09 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.