Description:
When a database is named using a reserved word (specifically aux, which is reserved on Windows/DOS), MySQL correctly encodes the directory on the file system (e.g., Linux path becomes ./data/aux@@@/).
However, if this database contains tables that use Partitioning (specifically subpartitions in the test case), InnoDB fails to correctly associate the tablespace files with the schema upon a server restart.
InnoDB throws error MY-013589, stating the file "cannot be opened because it is not in a sub-directory named for the schema." This suggests the logic that handles reserved-name decoding for directory paths is failing or not being applied during the directory scan for partitioned tablespaces.
How to repeat:
Run the following SQL script on a Linux MySQL instance (tested on 8.4.6):
-- 1. Create the reserved name database
DROP DATABASE IF EXISTS aux;
CREATE DATABASE aux;
USE aux;
-- 2. Create a partitioned and subpartitioned table
CREATE TABLE `sstool_20220907` (
`id` BIGINT NOT NULL,
`event_time` DATETIME NOT NULL,
`data` TEXT,
`PRIMARY KEY` (`id`, `event_time`)
)
PARTITION BY RANGE (TO_DAYS(`event_time`))
SUBPARTITION BY HASH (`id`) (
PARTITION p01 VALUES LESS THAN (TO_DAYS('2022-09-08')) (
SUBPARTITION p01sp1,
SUBPARTITION p01sp2
)
);
-- 3. Insert data to ensure .ibd files are populated
INSERT INTO sstool_20220907 (id, event_time, data) VALUES
(1, '2022-09-07 10:00:00', 'row1'),
(2, '2022-09-07 11:00:00', 'row2'),
(3, '2022-09-07 12:00:00', 'row3'),
(4, '2022-09-07 13:00:00', 'row4'),
(5, '2022-09-07 14:00:00', 'row5');
-- 4. Create a second table (optional, but confirms reproducibility across multiple files)
CREATE TABLE `sstool_20220908` (
`id` BIGINT NOT NULL,
`event_time` DATETIME NOT NULL,
`data` TEXT,
`PRIMARY KEY` (`id`, `event_time`)
)
PARTITION BY RANGE (TO_DAYS(`event_time`))
SUBPARTITION BY HASH (`id`) (
PARTITION p01 VALUES LESS THAN (TO_DAYS('2022-09-09')) (
SUBPARTITION p01sp1,
SUBPARTITION p01sp2
)
);
INSERT INTO sstool_20220908 (id, event_time, data) VALUES
(10, '2022-09-08 09:00:00', 'row1');
-- 5. RESTART the MySQL Server instance.
-- 6. Check the error log.
Actual Result (Error Log): Upon restart, InnoDB refuses to open the files, claiming directory mismatch, and subsequently marks the tablespaces as missing.
2025-12-03T16:41:38.828953Z 1 [ERROR] [MY-013589] [InnoDB] Scanned file '/home/vinicius.grippa/sandboxes/msb_8_4_6/data/aux@@@/sstool_20220907#p#p01#sp#p01sp1.ibd' for tablespace aux/sstool_20220907#p#p01#sp#p01sp1 cannot be opened because it is not in a sub-directory named for the schema.
2025-12-03T16:41:38.829057Z 1 [Warning] [MY-012351] [InnoDB] Tablespace 24, name 'aux/sstool_20220907#p#p01#sp#p01sp1', file './aux@@@/sstool_20220907#p#p01#sp#p01sp1.ibd' is missing!
2025-12-03T16:41:38.829200Z 1 [ERROR] [MY-013589] [InnoDB] Scanned file '/home/vinicius.grippa/sandboxes/msb_8_4_6/data/aux@@@/sstool_20220907#p#p01#sp#p01sp2.ibd' for tablespace aux/sstool_20220907#p#p01#sp#p01sp2 cannot be opened because it is not in a sub-directory named for the schema.
2025-12-03T16:41:38.829242Z 1 [Warning] [MY-012351] [InnoDB] Tablespace 25, name 'aux/sstool_20220907#p#p01#sp#p01sp2', file './aux@@@/sstool_20220907#p#p01#sp#p01sp2.ibd' is missing!
2025-12-03T16:41:38.829368Z 1 [ERROR] [MY-013589] [InnoDB] Scanned file '/home/vinicius.grippa/sandboxes/msb_8_4_6/data/aux@@@/sstool_20220908#p#p01#sp#p01sp1.ibd' for tablespace aux/sstool_20220908#p#p01#sp#p01sp1 cannot be opened because it is not in a sub-directory named for the schema.
2025-12-03T16:41:38.829409Z 1 [Warning] [MY-012351] [InnoDB] Tablespace 26, name 'aux/sstool_20220908#p#p01#sp#p01sp1', file './aux@@@/sstool_20220908#p#p01#sp#p01sp1.ibd' is missing!
2025-12-03T16:41:38.829554Z 1 [ERROR] [MY-013589] [InnoDB] Scanned file '/home/vinicius.grippa/sandboxes/msb_8_4_6/data/aux@@@/sstool_20220908#p#p01#sp#p01sp2.ibd' for tablespace aux/sstool_20220908#p#p01#sp#p01sp2 cannot be opened because it is not in a sub-directory named for the schema.
2025-12-03T16:41:38.829642Z 1 [Warning] [MY-012351] [InnoDB] Tablespace 27, name 'aux/sstool_20220908#p#p01#sp#p01sp2', file './aux@@@/sstool_20220908#p#p01#sp#p01sp2.ibd' is missing!
Suggested fix:
MySQL should recognize that the directory aux@@@ corresponds to the logical schema aux, validate the tablespace, and open the tables successfully without error, just as it does for non-partitioned tables in the same database.
Description: When a database is named using a reserved word (specifically aux, which is reserved on Windows/DOS), MySQL correctly encodes the directory on the file system (e.g., Linux path becomes ./data/aux@@@/). However, if this database contains tables that use Partitioning (specifically subpartitions in the test case), InnoDB fails to correctly associate the tablespace files with the schema upon a server restart. InnoDB throws error MY-013589, stating the file "cannot be opened because it is not in a sub-directory named for the schema." This suggests the logic that handles reserved-name decoding for directory paths is failing or not being applied during the directory scan for partitioned tablespaces. How to repeat: Run the following SQL script on a Linux MySQL instance (tested on 8.4.6): -- 1. Create the reserved name database DROP DATABASE IF EXISTS aux; CREATE DATABASE aux; USE aux; -- 2. Create a partitioned and subpartitioned table CREATE TABLE `sstool_20220907` ( `id` BIGINT NOT NULL, `event_time` DATETIME NOT NULL, `data` TEXT, `PRIMARY KEY` (`id`, `event_time`) ) PARTITION BY RANGE (TO_DAYS(`event_time`)) SUBPARTITION BY HASH (`id`) ( PARTITION p01 VALUES LESS THAN (TO_DAYS('2022-09-08')) ( SUBPARTITION p01sp1, SUBPARTITION p01sp2 ) ); -- 3. Insert data to ensure .ibd files are populated INSERT INTO sstool_20220907 (id, event_time, data) VALUES (1, '2022-09-07 10:00:00', 'row1'), (2, '2022-09-07 11:00:00', 'row2'), (3, '2022-09-07 12:00:00', 'row3'), (4, '2022-09-07 13:00:00', 'row4'), (5, '2022-09-07 14:00:00', 'row5'); -- 4. Create a second table (optional, but confirms reproducibility across multiple files) CREATE TABLE `sstool_20220908` ( `id` BIGINT NOT NULL, `event_time` DATETIME NOT NULL, `data` TEXT, `PRIMARY KEY` (`id`, `event_time`) ) PARTITION BY RANGE (TO_DAYS(`event_time`)) SUBPARTITION BY HASH (`id`) ( PARTITION p01 VALUES LESS THAN (TO_DAYS('2022-09-09')) ( SUBPARTITION p01sp1, SUBPARTITION p01sp2 ) ); INSERT INTO sstool_20220908 (id, event_time, data) VALUES (10, '2022-09-08 09:00:00', 'row1'); -- 5. RESTART the MySQL Server instance. -- 6. Check the error log. Actual Result (Error Log): Upon restart, InnoDB refuses to open the files, claiming directory mismatch, and subsequently marks the tablespaces as missing. 2025-12-03T16:41:38.828953Z 1 [ERROR] [MY-013589] [InnoDB] Scanned file '/home/vinicius.grippa/sandboxes/msb_8_4_6/data/aux@@@/sstool_20220907#p#p01#sp#p01sp1.ibd' for tablespace aux/sstool_20220907#p#p01#sp#p01sp1 cannot be opened because it is not in a sub-directory named for the schema. 2025-12-03T16:41:38.829057Z 1 [Warning] [MY-012351] [InnoDB] Tablespace 24, name 'aux/sstool_20220907#p#p01#sp#p01sp1', file './aux@@@/sstool_20220907#p#p01#sp#p01sp1.ibd' is missing! 2025-12-03T16:41:38.829200Z 1 [ERROR] [MY-013589] [InnoDB] Scanned file '/home/vinicius.grippa/sandboxes/msb_8_4_6/data/aux@@@/sstool_20220907#p#p01#sp#p01sp2.ibd' for tablespace aux/sstool_20220907#p#p01#sp#p01sp2 cannot be opened because it is not in a sub-directory named for the schema. 2025-12-03T16:41:38.829242Z 1 [Warning] [MY-012351] [InnoDB] Tablespace 25, name 'aux/sstool_20220907#p#p01#sp#p01sp2', file './aux@@@/sstool_20220907#p#p01#sp#p01sp2.ibd' is missing! 2025-12-03T16:41:38.829368Z 1 [ERROR] [MY-013589] [InnoDB] Scanned file '/home/vinicius.grippa/sandboxes/msb_8_4_6/data/aux@@@/sstool_20220908#p#p01#sp#p01sp1.ibd' for tablespace aux/sstool_20220908#p#p01#sp#p01sp1 cannot be opened because it is not in a sub-directory named for the schema. 2025-12-03T16:41:38.829409Z 1 [Warning] [MY-012351] [InnoDB] Tablespace 26, name 'aux/sstool_20220908#p#p01#sp#p01sp1', file './aux@@@/sstool_20220908#p#p01#sp#p01sp1.ibd' is missing! 2025-12-03T16:41:38.829554Z 1 [ERROR] [MY-013589] [InnoDB] Scanned file '/home/vinicius.grippa/sandboxes/msb_8_4_6/data/aux@@@/sstool_20220908#p#p01#sp#p01sp2.ibd' for tablespace aux/sstool_20220908#p#p01#sp#p01sp2 cannot be opened because it is not in a sub-directory named for the schema. 2025-12-03T16:41:38.829642Z 1 [Warning] [MY-012351] [InnoDB] Tablespace 27, name 'aux/sstool_20220908#p#p01#sp#p01sp2', file './aux@@@/sstool_20220908#p#p01#sp#p01sp2.ibd' is missing! Suggested fix: MySQL should recognize that the directory aux@@@ corresponds to the logical schema aux, validate the tablespace, and open the tables successfully without error, just as it does for non-partitioned tables in the same database.