summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-04-07 19:52:35 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-04-07 19:52:35 +0300
commitd9c85ee45a5b33ff823d8db1261d21426e89dfb0 (patch)
tree27ee8e6f390a18f44bf48e27751d6b6b38eaff0e /storage
parent4c89cff5582e786d1cde40b75c2290c136e64e31 (diff)
downloadmariadb-git-d9c85ee45a5b33ff823d8db1261d21426e89dfb0.tar.gz
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.
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/fil/fil0crypt.cc11
-rw-r--r--storage/xtradb/fil/fil0crypt.cc11
2 files changed, 18 insertions, 4 deletions
diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index a9e887ad10c..cb499121c86 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -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;
}
diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc
index a9e887ad10c..cb499121c86 100644
--- a/storage/xtradb/fil/fil0crypt.cc
+++ b/storage/xtradb/fil/fil0crypt.cc
@@ -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;
}