Skip to content

Commit 638ede5

Browse files
dr-mvuvova
authored andcommitted
MDEV-24864 Fatal error in buf_page_get_low() / fseg_page_is_free()
The fix of MDEV-24569 and MDEV-24695 introduced a race condition when a table is being rebuilt or dropped during the fseg_page_is_free() check. The server would occasionally crash during the execution of the test encryption.create_or_replace. The fil_space_t::STOPPING flag can be set by DDL operations. Normally, such concurrent operations are prevented by a metadata lock (MDL). However, neither the change buffer merge nor the fil_crypt_thread() are protected by MDL. fil_crypt_read_crypt_data(), xdes_get_descriptor_const(): Pass the BUF_GET_POSSIBLY_FREED flag to avoid the fatal error in buf_page_get_low() if a DDL operation was just initiated.
1 parent f13f966 commit 638ede5

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

storage/innobase/fil/fil0crypt.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
Copyright (C) 2013, 2015, Google Inc. All Rights Reserved.
3-
Copyright (c) 2014, 2020, MariaDB Corporation.
3+
Copyright (c) 2014, 2021, MariaDB Corporation.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -991,10 +991,13 @@ fil_crypt_read_crypt_data(fil_space_t* space)
991991
const ulint zip_size = space->zip_size();
992992
mtr_t mtr;
993993
mtr.start();
994-
if (buf_block_t* block = buf_page_get(page_id_t(space->id, 0),
995-
zip_size, RW_S_LATCH, &mtr)) {
994+
if (buf_block_t* block = buf_page_get_gen(page_id_t(space->id, 0),
995+
zip_size, RW_S_LATCH,
996+
nullptr,
997+
BUF_GET_POSSIBLY_FREED,
998+
__FILE__, __LINE__, &mtr)) {
996999
mutex_enter(&fil_system.mutex);
997-
if (!space->crypt_data) {
1000+
if (!space->crypt_data && !space->is_stopping()) {
9981001
space->crypt_data = fil_space_read_crypt_data(
9991002
zip_size, block->frame);
10001003
}

storage/innobase/fsp/fsp0fsp.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,11 @@ xdes_get_descriptor_const(
410410

411411
const ulint zip_size = space->zip_size();
412412

413-
if (buf_block_t* block = buf_page_get(page_id_t(space->id, page),
414-
zip_size, RW_S_LATCH, mtr)) {
413+
if (buf_block_t* block = buf_page_get_gen(page_id_t(space->id, page),
414+
zip_size, RW_S_LATCH,
415+
nullptr,
416+
BUF_GET_POSSIBLY_FREED,
417+
__FILE__, __LINE__, mtr)) {
415418
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
416419

417420
ut_ad(page != 0 || space->free_limit == mach_read_from_4(

0 commit comments

Comments
 (0)