Commit e2f570bf authored by Thirunarayanan Balathandayuthapani's avatar Thirunarayanan Balathandayuthapani Committed by Marko Mäkelä

MDEV-20320 Tablespace flags mismatch for full_crc32 format

Files for PAGE_COMPRESSED tables that were created with
innodb_checksum_algorithm=full_crc32 store the value of
innodb_compression_algorithm at the time of the file creation.

The server-wide setting of innodb_compression_algorithm
may be changed after file creation. We must ignore any mismatch
when opening a data file, and for writes, we must use the
choice of algorithm that is stored in the file.

fil_space_t::is_flags_full_crc32_equal(): Ignore the
innodb_compression_algorithm but do compare innodb_page_size.

fil_space_t::is_flags_non_full_crc32_equal(): Ignore the
innodb_compression_algorithm.
parent 13f74090
...@@ -127,3 +127,51 @@ Table Op Msg_type Msg_text ...@@ -127,3 +127,51 @@ Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
InnoDB 0 transactions not purged InnoDB 0 transactions not purged
DROP TABLE t1; DROP TABLE t1;
SET @save_algo = @@GLOBAL.innodb_compression_algorithm;
SET GLOBAL innodb_compression_algorithm=2;
CREATE TABLE t1(a SERIAL) PAGE_COMPRESSED=1 ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
FLUSH TABLE t1 FOR EXPORT;
# List before copying files
db.opt
t1.cfg
t1.frm
t1.ibd
backup: t1
UNLOCK TABLES;
SET GLOBAL innodb_compression_algorithm=0;
ALTER TABLE t1 FORCE;
ALTER TABLE t1 DISCARD TABLESPACE;
db.opt
t1.frm
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
INSERT INTO t1 VALUES(2);
SELECT * FROM t1;
a
1
2
SET GLOBAL innodb_compression_algorithm=3;
FLUSH TABLE t1 FOR EXPORT;
# List before copying files
db.opt
t1.cfg
t1.frm
t1.ibd
backup: t1
UNLOCK TABLES;
SET GLOBAL innodb_compression_algorithm=0;
ALTER TABLE t1 FORCE;
ALTER TABLE t1 DISCARD TABLESPACE;
db.opt
t1.frm
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
a
1
2
3
DROP TABLE t1;
SET GLOBAL innodb_compression_algorithm=@save_algo;
...@@ -137,3 +137,64 @@ DELETE FROM t1; ...@@ -137,3 +137,64 @@ DELETE FROM t1;
CHECK TABLE t1; CHECK TABLE t1;
--source include/wait_all_purged.inc --source include/wait_all_purged.inc
DROP TABLE t1; DROP TABLE t1;
SET @save_algo = @@GLOBAL.innodb_compression_algorithm;
SET GLOBAL innodb_compression_algorithm=2;
CREATE TABLE t1(a SERIAL) PAGE_COMPRESSED=1 ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
FLUSH TABLE t1 FOR EXPORT;
--echo # List before copying files
let MYSQLD_DATADIR =`SELECT @@datadir`;
--list_files $MYSQLD_DATADIR/test
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_backup_tablespaces("test", "t1");
EOF
UNLOCK TABLES;
SET GLOBAL innodb_compression_algorithm=0;
ALTER TABLE t1 FORCE;
ALTER TABLE t1 DISCARD TABLESPACE;
--list_files $MYSQLD_DATADIR/test
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
ALTER TABLE t1 IMPORT TABLESPACE;
INSERT INTO t1 VALUES(2);
SELECT * FROM t1;
SET GLOBAL innodb_compression_algorithm=3;
FLUSH TABLE t1 FOR EXPORT;
--echo # List before copying files
let MYSQLD_DATADIR =`SELECT @@datadir`;
--list_files $MYSQLD_DATADIR/test
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_backup_tablespaces("test", "t1");
EOF
UNLOCK TABLES;
SET GLOBAL innodb_compression_algorithm=0;
ALTER TABLE t1 FORCE;
ALTER TABLE t1 DISCARD TABLESPACE;
--list_files $MYSQLD_DATADIR/test
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
ALTER TABLE t1 IMPORT TABLESPACE;
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
DROP TABLE t1;
SET GLOBAL innodb_compression_algorithm=@save_algo;
...@@ -395,13 +395,16 @@ struct fil_space_t { ...@@ -395,13 +395,16 @@ struct fil_space_t {
static bool is_flags_full_crc32_equal(ulint flags, ulint expected) static bool is_flags_full_crc32_equal(ulint flags, ulint expected)
{ {
ut_ad(full_crc32(flags)); ut_ad(full_crc32(flags));
ulint page_ssize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags);
if (full_crc32(expected)) { if (full_crc32(expected)) {
return get_compression_algo(flags) /* The data file may have been created with a
== get_compression_algo(expected); different innodb_compression_algorithm. But
we only support one innodb_page_size for all files. */
return page_ssize
== FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(expected);
} }
ulint page_ssize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags);
ulint space_page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(expected); ulint space_page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(expected);
if (page_ssize == 5) { if (page_ssize == 5) {
...@@ -412,7 +415,7 @@ struct fil_space_t { ...@@ -412,7 +415,7 @@ struct fil_space_t {
return false; return false;
} }
return is_compressed(expected) == is_compressed(flags); return true;
} }
/** Whether old tablespace flags match full_crc32 flags. /** Whether old tablespace flags match full_crc32 flags.
@param[in] flags flags present @param[in] flags flags present
...@@ -438,7 +441,7 @@ struct fil_space_t { ...@@ -438,7 +441,7 @@ struct fil_space_t {
return false; return false;
} }
return is_compressed(expected) == is_compressed(flags); return true;
} }
/** Whether both fsp flags are equivalent */ /** Whether both fsp flags are equivalent */
static bool is_flags_equal(ulint flags, ulint expected) static bool is_flags_equal(ulint flags, ulint expected)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment