-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-26131 SEGV in ha_innobase::discard_or_import_tablespace
Import operation without .cfg file fails when there is mismatch of index between metadata table and .ibd file. Moreover, MDEV-19022 shows that InnoDB can end up with index tree where non-leaf page has only one child page. So it is unsafe to find the secondary index root page. This patch does the following when importing the table without .cfg file: 1) If the metadata contains more than one index then InnoDB stops the import operation and report the user to drop all secondary indexes before doing import operation. 2) When the metadata contain only clustered index then InnoDB finds the index id by reading page 0 & page 3 instead of traversing the whole tablespace.
- Loading branch information
1 parent
4cd063b
commit 89445b6
Showing
6 changed files
with
246 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# MDEV-26131 SEGV in ha_innobase::discard_or_import_tablespace | ||
# | ||
CREATE TABLE t1(f1 int,f2 text)ENGINE=InnoDB; | ||
INSERT INTO t1 VALUES(1, "InnoDB"); | ||
CREATE TABLE t2 LIKE t1; | ||
ALTER TABLE t2 ADD KEY idx (f2(13)); | ||
ALTER TABLE t2 DISCARD TABLESPACE; | ||
FLUSH TABLES t1 FOR EXPORT; | ||
UNLOCK TABLES; | ||
ALTER TABLE t2 IMPORT TABLESPACE; | ||
ERROR HY000: Internal error: Drop all secondary indexes before importing table test/t2 when .cfg file is missing. | ||
ALTER TABLE t2 DROP KEY idx; | ||
Warnings: | ||
Warning 1814 Tablespace has been discarded for table `t2` | ||
ALTER TABLE t2 IMPORT TABLESPACE; | ||
Warnings: | ||
Warning 1810 IO Read error: (2, No such file or directory) Error opening './test/t2.cfg', will attempt to import without schema verification | ||
SELECT * FROM t2; | ||
f1 f2 | ||
1 InnoDB | ||
DROP TABLE t1, t2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[page_compressed] | ||
innodb-compression-default=1 | ||
[encryption] | ||
innodb-encrypt-tables=1 | ||
[page_compressed_encryption] | ||
innodb-compression-default=1 | ||
innodb-encrypt-tables=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--source include/have_innodb.inc | ||
-- source include/have_example_key_management_plugin.inc | ||
--echo # | ||
--echo # MDEV-26131 SEGV in ha_innobase::discard_or_import_tablespace | ||
--echo # | ||
let $MYSQLD_DATADIR = `SELECT @@datadir`; | ||
CREATE TABLE t1(f1 int,f2 text)ENGINE=InnoDB; | ||
INSERT INTO t1 VALUES(1, "InnoDB"); | ||
CREATE TABLE t2 LIKE t1; | ||
ALTER TABLE t2 ADD KEY idx (f2(13)); | ||
ALTER TABLE t2 DISCARD TABLESPACE; | ||
FLUSH TABLES t1 FOR EXPORT; | ||
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd | ||
UNLOCK TABLES; | ||
--error ER_INTERNAL_ERROR | ||
ALTER TABLE t2 IMPORT TABLESPACE; | ||
|
||
ALTER TABLE t2 DROP KEY idx; | ||
ALTER TABLE t2 IMPORT TABLESPACE; | ||
SELECT * FROM t2; | ||
DROP TABLE t1, t2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.