Commit 62b5a561 authored by Jan Lindström's avatar Jan Lindström

MDEV-8501: encryption.create_or_replace fails in buildbot on P8 builders

Analysis: There is race between drop table and encryption threads that
could cause encryption thread to enter mutex that has been already
released.

Fix: When destroying crypt_data first enter the mutex and set crypt data
unavailable, then release the memory and clean up the data. This should
make the race more unprobable. Additionally, added big_test for
create_or_replace as it could fail testcase timeout
if you have slow I/O (tested that testcase passes with --mem).
parent 6d3bd658
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_file_key_management_plugin.inc --source include/have_file_key_management_plugin.inc
--source include/not_embedded.inc --source include/not_embedded.inc
# This is needed for longer testcase timeout at least P7/P8
--source include/big_test.inc
# #
# MDEV-8164: Server crashes in pfs_mutex_enter_func after fil_crypt_is_closing or alike # MDEV-8164: Server crashes in pfs_mutex_enter_func after fil_crypt_is_closing or alike
......
...@@ -364,7 +364,13 @@ fil_space_destroy_crypt_data( ...@@ -364,7 +364,13 @@ fil_space_destroy_crypt_data(
fil_space_crypt_t **crypt_data) /*!< out: crypt data */ fil_space_crypt_t **crypt_data) /*!< out: crypt data */
{ {
if (crypt_data != NULL && (*crypt_data) != NULL) { if (crypt_data != NULL && (*crypt_data) != NULL) {
mutex_free(& (*crypt_data)->mutex); /* Make sure that this thread owns the crypt_data
and make it unawailable, this does not fully
avoid the race between drop table and crypt thread */
mutex_enter(&(*crypt_data)->mutex);
(*crypt_data)->inited = false;
mutex_exit(&(*crypt_data)->mutex);
mutex_free(&(*crypt_data)->mutex);
memset(*crypt_data, 0, sizeof(fil_space_crypt_t)); memset(*crypt_data, 0, sizeof(fil_space_crypt_t));
free(*crypt_data); free(*crypt_data);
(*crypt_data) = NULL; (*crypt_data) = NULL;
......
...@@ -364,6 +364,12 @@ fil_space_destroy_crypt_data( ...@@ -364,6 +364,12 @@ fil_space_destroy_crypt_data(
fil_space_crypt_t **crypt_data) /*!< out: crypt data */ fil_space_crypt_t **crypt_data) /*!< out: crypt data */
{ {
if (crypt_data != NULL && (*crypt_data) != NULL) { if (crypt_data != NULL && (*crypt_data) != NULL) {
/* Make sure that this thread owns the crypt_data
and make it unawailable, this does not fully
avoid the race between drop table and crypt thread */
mutex_enter(&(*crypt_data)->mutex);
(*crypt_data)->inited = false;
mutex_exit(&(*crypt_data)->mutex);
mutex_free(& (*crypt_data)->mutex); mutex_free(& (*crypt_data)->mutex);
memset(*crypt_data, 0, sizeof(fil_space_crypt_t)); memset(*crypt_data, 0, sizeof(fil_space_crypt_t));
free(*crypt_data); free(*crypt_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