diff --git a/mysql-test/suite/encryption/t/create_or_replace.test b/mysql-test/suite/encryption/t/create_or_replace.test index ca68f950588..3b2970e5162 100644 --- a/mysql-test/suite/encryption/t/create_or_replace.test +++ b/mysql-test/suite/encryption/t/create_or_replace.test @@ -1,6 +1,8 @@ --source include/have_innodb.inc --source include/have_file_key_management_plugin.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 diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index d5b942a652b..4efaaefe72f 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -364,7 +364,13 @@ fil_space_destroy_crypt_data( fil_space_crypt_t **crypt_data) /*!< out: crypt data */ { 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)); free(*crypt_data); (*crypt_data) = NULL; diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index a60e55f3de6..0358ce44bd7 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -364,6 +364,12 @@ fil_space_destroy_crypt_data( fil_space_crypt_t **crypt_data) /*!< out: crypt data */ { 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); memset(*crypt_data, 0, sizeof(fil_space_crypt_t)); free(*crypt_data);