Commit afe00bb7 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-25998 fixup: Avoid a hang

btr_scrub_start_space(): Avoid an unnecessary tablespace lookup
and related acquisition of fil_system->mutex. In MariaDB Server 10.3
we would get deadlocks between that mutex and a crypt_data mutex.

The fix was developed by Thirunarayanan Balathandayuthapani.
parent e11cae71
// Copyright (c) 2014, Google Inc. // Copyright (c) 2014, Google Inc.
// Copyright (c) 2017, MariaDB Corporation. // Copyright (c) 2017, 2021, MariaDB Corporation.
/**************************************************//** /**************************************************//**
@file btr/btr0scrub.cc @file btr/btr0scrub.cc
...@@ -835,20 +835,12 @@ btr_scrub_page( ...@@ -835,20 +835,12 @@ btr_scrub_page(
/**************************************************************//** /**************************************************************//**
Start iterating a space */ Start iterating a space */
UNIV_INTERN bool btr_scrub_start_space(const fil_space_t &space, btr_scrub_t *scrub_data)
bool
btr_scrub_start_space(
/*===================*/
ulint space, /*!< in: space */
btr_scrub_t* scrub_data) /*!< in/out: scrub data */
{ {
bool found; scrub_data->space = space.id;
scrub_data->space = space;
scrub_data->current_table = NULL; scrub_data->current_table = NULL;
scrub_data->current_index = NULL; scrub_data->current_index = NULL;
const page_size_t page_size = fil_space_get_page_size(space, &found); scrub_data->compressed = FSP_FLAGS_GET_ZIP_SSIZE(space.flags) != 0;
scrub_data->compressed = page_size.is_compressed();
scrub_data->scrubbing = check_scrub_setting(scrub_data); scrub_data->scrubbing = check_scrub_setting(scrub_data);
return scrub_data->scrubbing; return scrub_data->scrubbing;
} }
......
...@@ -1200,7 +1200,7 @@ fil_crypt_space_needs_rotation( ...@@ -1200,7 +1200,7 @@ fil_crypt_space_needs_rotation(
key_state->rotate_key_age); key_state->rotate_key_age);
crypt_data->rotate_state.scrubbing.is_active = crypt_data->rotate_state.scrubbing.is_active =
btr_scrub_start_space(space->id, &state->scrub_data); btr_scrub_start_space(*space, &state->scrub_data);
time_t diff = time(0) - crypt_data->rotate_state.scrubbing. time_t diff = time(0) - crypt_data->rotate_state.scrubbing.
last_scrub_completed; last_scrub_completed;
......
...@@ -141,12 +141,7 @@ btr_scrub_skip_page( ...@@ -141,12 +141,7 @@ btr_scrub_skip_page(
/**************************************************************** /****************************************************************
Start iterating a space Start iterating a space
* @return true if scrubbing is turned on */ * @return true if scrubbing is turned on */
UNIV_INTERN bool btr_scrub_start_space(const fil_space_t &space, btr_scrub_t *scrub_data);
bool
btr_scrub_start_space(
/*===================*/
ulint space, /*!< in: space */
btr_scrub_t* scrub_data); /*!< in/out: scrub data */
/** Complete iterating a space. /** Complete iterating a space.
@param[in,out] scrub_data scrub data */ @param[in,out] scrub_data scrub data */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment