MDEV-15752 Possible race between DDL and accessing I_S.INNODB_TABLESPACES_ENCRYPTION

fil_crypt_read_crypt_data(): Do not attempt to read the tablespace
if the file is unaccessible due to a pending DDL operation, such as
renaming the file or DROP TABLE or TRUNCATE TABLE. This is only
reducing the probability of the race condition, not completely
preventing it.
This commit is contained in:
Marko Mäkelä 2018-04-07 19:52:35 +03:00
parent 4c89cff558
commit d9c85ee45a
2 changed files with 18 additions and 4 deletions

View file

@ -1016,10 +1016,17 @@ static inline
void
fil_crypt_read_crypt_data(fil_space_t* space)
{
if (space->crypt_data || space->size) {
if (space->crypt_data || space->size
|| !fil_space_get_size(space->id)) {
/* The encryption metadata has already been read, or
the tablespace is not encrypted and the file has been
opened already. */
opened already, or the file cannot be accessed,
likely due to a concurrent TRUNCATE or
RENAME or DROP (possibly as part of ALTER TABLE).
FIXME: The file can become unaccessible any time
after this check! We should really remove this
function and instead make crypt_data an integral
part of fil_space_t. */
return;
}

View file

@ -1016,10 +1016,17 @@ static inline
void
fil_crypt_read_crypt_data(fil_space_t* space)
{
if (space->crypt_data || space->size) {
if (space->crypt_data || space->size
|| !fil_space_get_size(space->id)) {
/* The encryption metadata has already been read, or
the tablespace is not encrypted and the file has been
opened already. */
opened already, or the file cannot be accessed,
likely due to a concurrent TRUNCATE or
RENAME or DROP (possibly as part of ALTER TABLE).
FIXME: The file can become unaccessible any time
after this check! We should really remove this
function and instead make crypt_data an integral
part of fil_space_t. */
return;
}