From 5d06230ae2a1c6439a036e2b13da7d7010c35473 Mon Sep 17 00:00:00 2001 From: Rahul Sisondia Date: Wed, 20 Mar 2024 19:21:22 +0100 Subject: [PATCH] Bug#36343647 [ERROR] [MY-013183] [InnoDB] Assertion failure:ibuf0ibuf.cc:3833:ib::fatal This is a cherry-pick of the following bug fix which is already fixed in 8.4 through commit#79d67. Bug#35676106 Assertion failure: ibuf0ibuf.cc:3825:ib::fatal triggered thread Description: ------------ When the pages of secondary index are brought to the buffer pool either through the ibuf merge background thread or read through usual io thread, first cached entries from the change buffer are applied to the pages. Once the entries are applied to the page, they are removed from the change buffer. It may possible that the table is deleted or being deleted during change buffer related operations described in the earlier. In the current code we handled the situation of tablespace is deleted but not being deleted. Latter situation must also be handled similarly. Fix: ==== - Replaced the call fil_space_get_flags() with fil_space_acquire_silent(). Later method refuses to acquire the tablespace that is being deleted. - Improved the doxygen of the method ibuf_restore_pos() Change-Id: Ibc5a07c705988282b8b7906d645e2a108f4ada76 --- storage/innobase/ibuf/ibuf0ibuf.cc | 31 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 9fd6491a1ca1..1c74075cb92b 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -3791,18 +3791,16 @@ static void ibuf_delete(const dtuple_t *entry, /*!< in: entry */ } /** Restores insert buffer tree cursor position - @return true if the position was restored; false if not */ -static bool ibuf_restore_pos( - space_id_t space, /*!< in: space id */ - page_no_t page_no, /*!< in: index page number where the record - should belong */ - const dtuple_t *search_tuple, - /*!< in: search tuple for entries of page_no */ - ulint mode, /*!< in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE */ - btr_pcur_t *pcur, /*!< in/out: persistent cursor whose - position is to be restored */ - mtr_t *mtr) /*!< in/out: mini-transaction */ -{ +@param[in] space_id Tablespace id +@param[in] page_no index page number where the record should belong +@param [in] search_tuple search tuple for entries of page_no +@param[in] mode BTR_MODIFY_LEAF or BTR_MODIFY_TREE +@param[in,out] pcur persistent cursor whose position is to be restored +@param[in, out] mtr mini-transaction +@return true if the position was restored; false if not */ +static bool ibuf_restore_pos(space_id_t space_id, page_no_t page_no, + const dtuple_t *search_tuple, ulint mode, + btr_pcur_t *pcur, mtr_t *mtr) { ut_ad(mode == BTR_MODIFY_LEAF || BTR_LATCH_MODE_WITHOUT_INTENTION(mode) == BTR_MODIFY_TREE); @@ -3810,15 +3808,14 @@ static bool ibuf_restore_pos( return true; } - if (fil_space_get_flags(space) == UINT32_UNDEFINED) { - /* The tablespace has been dropped. It is possible - that another thread has deleted the insert buffer - entry. Do not complain. */ + if (const auto space = fil_space_acquire_silent(space_id); space == nullptr) { + /* The tablespace has been(or being) deleted. Do not complain. */ ibuf_btr_pcur_commit_specify_mtr(pcur, mtr); } else { + fil_space_release(space); ib::error(ER_IB_MSG_620) << "ibuf cursor restoration fails!." " ibuf record inserted to page " - << space << ":" << page_no; + << space_id << ":" << page_no; ib::error(ER_IB_MSG_621) << BUG_REPORT_MSG;