[MDEV-27500] buf_page_free() fails to drop the adaptive hash index Created: 2022-01-14  Updated: 2022-01-14  Resolved: 2022-01-14

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.5, 10.6, 10.7, 10.8
Fix Version/s: 10.5.14, 10.6.6, 10.7.2, 10.8.1

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: rr-profile-analyzed

Issue Links:
Problem/Incident
is caused by MDEV-15528 Avoid writing freed InnoDB pages Closed

 Description   

In a recent test run on 10.6, we got an assertion failure on shutdown:

10.6 e6a06113880fe3842fe7068d42bcae8bb02ab024

Thread 1 received signal SIGUSR1, User defined signal 1.
0x0000000070000002 in syscall_traced ()
(rr) c
Continuing.
2022-01-13 12:10:28 0 [Note] /data/Server_bin/10.6M_asan/bin/mysqld (initiated by: root[root] @ localhost [127.0.0.1]): Normal shutdown
2022-01-13 12:10:28 0 [Warning] Aborted connection 80 to db: 'mysql' user: 'root' host: 'localhost' (KILLED)
2022-01-13 12:10:28 0 [Warning] Aborted connection 15 to db: 'mysql' user: 'root' host: 'localhost' (KILLED)
2022-01-13 12:10:28 15 [Warning] Aborted connection 15 to db: 'mysql' user: 'root' host: 'localhost' (This connection closed normally)
2022-01-13 12:10:29 80 [Warning] Aborted connection 80 to db: 'mysql' user: 'root' host: 'localhost' (This connection closed normally)
2022-01-13 12:10:29 0 [Note] InnoDB: FTS optimize thread exiting.
2022-01-13 12:10:29 0 [Note] InnoDB: Starting shutdown...
2022-01-13 12:10:29 0 [Note] InnoDB: Dumping buffer pool(s) to /data/rqg/1642089155/22/1/data/ib_buffer_pool
2022-01-13 12:10:29 0 [Note] InnoDB: Buffer pool(s) dump completed at 220113 12:10:29
mysqld: /data/Server/10.6M/storage/innobase/btr/btr0sea.cc:942: void buf_pool_t::clear_hash_index(): Assertion `s >= buf_page_t::UNFIXED || s == buf_page_t::REMOVE_HASH' failed.
[New Thread 95798.194791]

This assertion is stricter since MDEV-27058. Previously, it did not assert that the page has not been marked as free. I think that the following (untested) patch for 10.6 should fix the cause of this bug:

diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 11d820be305..93934dd2b5b 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -2238,6 +2238,10 @@ void buf_page_free(fil_space_t *space, uint32_t page, mtr_t *mtr)
   }
 
   block->page.lock.x_lock();
+#ifdef BTR_CUR_HASH_ADAPT
+  if (block->index)
+    btr_search_drop_page_hash_index(block);
+#endif /* BTR_CUR_HASH_ADAPT */
   block->page.set_freed(block->page.state());
   mtr->memo_push(block, MTR_MEMO_PAGE_X_FIX);
 }

The 10.5 version is slightly different:

diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 37f99a94cee..7be40ac38e7 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -2500,6 +2500,11 @@ void buf_page_free(fil_space_t *space, uint32_t page, mtr_t *mtr,
       rw_lock_x_lock_inline(&block->lock, 0, file, line);
       buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
 
+#ifdef BTR_CUR_HASH_ADAPT
+      if (block->index)
+        btr_search_drop_page_hash_index(block);
+#endif /* BTR_CUR_HASH_ADAPT */
+
       block->page.status= buf_page_t::FREED;
       return;
     }

mleich, can you please test these?



 Comments   
Comment by Matthias Leich [ 2022-01-14 ]

When using origin/10.6 e6a06113880fe3842fe7068d42bcae8bb02ab024 2022-01-13T16:45:31+02:00
and some simplified test which replays faster
- patch from above not applied: The first replay comes after a few hundred RQG tests.
- patch from above applied:   I gave up after ~ 4000 RQG tests which just "passed.

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