Skip to content

Commit

Permalink
Bug#36343647 [ERROR] [MY-013183] [InnoDB] Assertion failure:ibuf0ibuf…
Browse files Browse the repository at this point in the history
….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
  • Loading branch information
RahulSisondia authored and nawazn committed Mar 27, 2024
1 parent 4aa1d53 commit 5d06230
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions storage/innobase/ibuf/ibuf0ibuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3791,34 +3791,31 @@ 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);

if (pcur->restore_position(mode, mtr, UT_LOCATION_HERE)) {
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;

Expand Down

0 comments on commit 5d06230

Please sign in to comment.