Commit e555540a authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-13105 InnoDB fails to load a table with PAGE_COMPRESSION_LEVEL after upgrade from 10.1.20

When using innodb_page_size=16k, InnoDB tables
that were created in MariaDB 10.1.0 to 10.1.20 with
PAGE_COMPRESSED=1 and
PAGE_COMPRESSION_LEVEL=2 or PAGE_COMPRESSION_LEVEL=3
would fail to load.

fsp_flags_is_valid(): When using innodb_page_size=16k, use a
more strict check for .ibd files, with the assumption that
nobody would try to use different-page-size files.
parent 8ae9c86f
...@@ -11,7 +11,7 @@ sub convert_to_mariadb_101 ...@@ -11,7 +11,7 @@ sub convert_to_mariadb_101
# FIL_PAGE_DATA + FSP_SPACE_FLAGS = 38 + 16 = 54 bytes from the start # FIL_PAGE_DATA + FSP_SPACE_FLAGS = 38 + 16 = 54 bytes from the start
my($flags) = unpack "x[54]N", $_; my($flags) = unpack "x[54]N", $_;
my $badflags = ($flags & 0x3f); my $badflags = ($flags & 0x3f);
my $compression_level=6; my $compression_level=3;
$badflags |= 1<<6|$compression_level<<7 if ($flags & 1 << 16); $badflags |= 1<<6|$compression_level<<7 if ($flags & 1 << 16);
$badflags |= ($flags & 15 << 6) << 7; # PAGE_SSIZE $badflags |= ($flags & 15 << 6) << 7; # PAGE_SSIZE
......
...@@ -7,7 +7,7 @@ CREATE TABLE tc(a INT)ENGINE=InnoDB ROW_FORMAT=COMPACT; ...@@ -7,7 +7,7 @@ CREATE TABLE tc(a INT)ENGINE=InnoDB ROW_FORMAT=COMPACT;
CREATE TABLE td(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC; CREATE TABLE td(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
CREATE TABLE tz(a INT)ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; CREATE TABLE tz(a INT)ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
CREATE TABLE tdd(a INT) ENGINE=InnoDB, DATA DIRECTORY='MYSQL_TMP_DIR'; CREATE TABLE tdd(a INT) ENGINE=InnoDB, DATA DIRECTORY='MYSQL_TMP_DIR';
CREATE TABLE tp(a INT) ENGINE=InnoDB page_compressed=1; CREATE TABLE tp(a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC PAGE_COMPRESSED=1;
CREATE TABLE ti(a INT) ENGINE=InnoDB; CREATE TABLE ti(a INT) ENGINE=InnoDB;
FLUSH TABLES ti FOR EXPORT; FLUSH TABLES ti FOR EXPORT;
backup: ti backup: ti
......
...@@ -28,7 +28,7 @@ CREATE TABLE tz(a INT)ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; ...@@ -28,7 +28,7 @@ CREATE TABLE tz(a INT)ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
EVAL CREATE TABLE tdd(a INT) ENGINE=InnoDB, DATA DIRECTORY='$MYSQL_TMP_DIR'; EVAL CREATE TABLE tdd(a INT) ENGINE=InnoDB, DATA DIRECTORY='$MYSQL_TMP_DIR';
CREATE TABLE tp(a INT) ENGINE=InnoDB page_compressed=1; CREATE TABLE tp(a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC PAGE_COMPRESSED=1;
CREATE TABLE ti(a INT) ENGINE=InnoDB; CREATE TABLE ti(a INT) ENGINE=InnoDB;
FLUSH TABLES ti FOR EXPORT; FLUSH TABLES ti FOR EXPORT;
perl; perl;
......
...@@ -616,7 +616,7 @@ buf_dblwr_process() ...@@ -616,7 +616,7 @@ buf_dblwr_process()
if (page_no == 0) { if (page_no == 0) {
/* Check the FSP_SPACE_FLAGS. */ /* Check the FSP_SPACE_FLAGS. */
ulint flags = fsp_header_get_flags(page); ulint flags = fsp_header_get_flags(page);
if (!fsp_flags_is_valid(flags) if (!fsp_flags_is_valid(flags, space_id)
&& fsp_flags_convert_from_101(flags) && fsp_flags_convert_from_101(flags)
== ULINT_UNDEFINED) { == ULINT_UNDEFINED) {
ib_logf(IB_LOG_LEVEL_WARN, ib_logf(IB_LOG_LEVEL_WARN,
......
...@@ -662,7 +662,7 @@ fil_node_open_file( ...@@ -662,7 +662,7 @@ fil_node_open_file(
ut_free(buf2); ut_free(buf2);
os_file_close(node->handle); os_file_close(node->handle);
if (!fsp_flags_is_valid(flags)) { if (!fsp_flags_is_valid(flags, space->id)) {
ulint cflags = fsp_flags_convert_from_101(flags); ulint cflags = fsp_flags_convert_from_101(flags);
if (cflags == ULINT_UNDEFINED) { if (cflags == ULINT_UNDEFINED) {
ib_logf(IB_LOG_LEVEL_ERROR, ib_logf(IB_LOG_LEVEL_ERROR,
...@@ -2366,7 +2366,7 @@ fil_read_first_page( ...@@ -2366,7 +2366,7 @@ fil_read_first_page(
FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
} }
if (!fsp_flags_is_valid(*flags)) { if (!fsp_flags_is_valid(*flags, *space_id)) {
ulint cflags = fsp_flags_convert_from_101(*flags); ulint cflags = fsp_flags_convert_from_101(*flags);
if (cflags == ULINT_UNDEFINED) { if (cflags == ULINT_UNDEFINED) {
ib_logf(IB_LOG_LEVEL_ERROR, ib_logf(IB_LOG_LEVEL_ERROR,
...@@ -2497,7 +2497,7 @@ fil_op_write_log( ...@@ -2497,7 +2497,7 @@ fil_op_write_log(
ulint len; ulint len;
log_ptr = mlog_open(mtr, 11 + 2 + 1); log_ptr = mlog_open(mtr, 11 + 2 + 1);
ut_ad(fsp_flags_is_valid(flags)); ut_ad(fsp_flags_is_valid(flags, space_id));
if (!log_ptr) { if (!log_ptr) {
/* Logging in mtr is switched off during crash recovery: /* Logging in mtr is switched off during crash recovery:
...@@ -3718,7 +3718,7 @@ fil_create_new_single_table_tablespace( ...@@ -3718,7 +3718,7 @@ fil_create_new_single_table_tablespace(
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
ut_a(space_id < SRV_LOG_SPACE_FIRST_ID); ut_a(space_id < SRV_LOG_SPACE_FIRST_ID);
ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE); ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE);
ut_a(fsp_flags_is_valid(flags & ~FSP_FLAGS_MEM_MASK)); ut_a(fsp_flags_is_valid(flags & ~FSP_FLAGS_MEM_MASK, space_id));
if (is_temp) { if (is_temp) {
/* Temporary table filepath */ /* Temporary table filepath */
...@@ -3979,7 +3979,7 @@ void ...@@ -3979,7 +3979,7 @@ void
fsp_flags_try_adjust(ulint space_id, ulint flags) fsp_flags_try_adjust(ulint space_id, ulint flags)
{ {
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
ut_ad(fsp_flags_is_valid(flags)); ut_ad(fsp_flags_is_valid(flags, space_id));
mtr_t mtr; mtr_t mtr;
mtr_start(&mtr); mtr_start(&mtr);
...@@ -4061,7 +4061,7 @@ fil_open_single_table_tablespace( ...@@ -4061,7 +4061,7 @@ fil_open_single_table_tablespace(
return(DB_CORRUPTION); return(DB_CORRUPTION);
} }
ut_ad(fsp_flags_is_valid(flags & ~FSP_FLAGS_MEM_MASK)); ut_ad(fsp_flags_is_valid(flags & ~FSP_FLAGS_MEM_MASK, id));
atomic_writes = fsp_flags_get_atomic_writes(flags); atomic_writes = fsp_flags_get_atomic_writes(flags);
memset(&def, 0, sizeof(def)); memset(&def, 0, sizeof(def));
...@@ -4601,7 +4601,7 @@ fil_user_tablespace_restore_page( ...@@ -4601,7 +4601,7 @@ fil_user_tablespace_restore_page(
flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page); flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page);
if (!fsp_flags_is_valid(flags)) { if (!fsp_flags_is_valid(flags, fsp->id)) {
ulint cflags = fsp_flags_convert_from_101(flags); ulint cflags = fsp_flags_convert_from_101(flags);
if (cflags == ULINT_UNDEFINED) { if (cflags == ULINT_UNDEFINED) {
ib_logf(IB_LOG_LEVEL_WARN, ib_logf(IB_LOG_LEVEL_WARN,
......
...@@ -661,7 +661,7 @@ fsp_header_init_fields( ...@@ -661,7 +661,7 @@ fsp_header_init_fields(
ulint flags) /*!< in: tablespace flags (FSP_SPACE_FLAGS) */ ulint flags) /*!< in: tablespace flags (FSP_SPACE_FLAGS) */
{ {
flags &= ~FSP_FLAGS_MEM_MASK; flags &= ~FSP_FLAGS_MEM_MASK;
ut_a(fsp_flags_is_valid(flags)); ut_a(fsp_flags_is_valid(flags, space_id));
mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page, mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page,
space_id); space_id);
......
...@@ -934,7 +934,7 @@ dict_tf_to_fsp_flags( ...@@ -934,7 +934,7 @@ dict_tf_to_fsp_flags(
fsp_flags |= FSP_FLAGS_MASK_PAGE_COMPRESSION; fsp_flags |= FSP_FLAGS_MASK_PAGE_COMPRESSION;
} }
ut_a(fsp_flags_is_valid(fsp_flags)); ut_a(fsp_flags_is_valid(fsp_flags, false));
if (DICT_TF_HAS_DATA_DIR(table_flags)) { if (DICT_TF_HAS_DATA_DIR(table_flags)) {
fsp_flags |= 1U << FSP_FLAGS_MEM_DATA_DIR; fsp_flags |= 1U << FSP_FLAGS_MEM_DATA_DIR;
......
...@@ -788,11 +788,12 @@ fseg_print( ...@@ -788,11 +788,12 @@ fseg_print(
/** Validate the tablespace flags, which are stored in the /** Validate the tablespace flags, which are stored in the
tablespace header at offset FSP_SPACE_FLAGS. tablespace header at offset FSP_SPACE_FLAGS.
@param[in] flags the contents of FSP_SPACE_FLAGS @param[in] flags the contents of FSP_SPACE_FLAGS
@param[in] is_ibd whether this is an .ibd file (not system tablespace)
@return whether the flags are correct (not in the buggy 10.1) format */ @return whether the flags are correct (not in the buggy 10.1) format */
MY_ATTRIBUTE((warn_unused_result, const)) MY_ATTRIBUTE((warn_unused_result, const))
UNIV_INLINE UNIV_INLINE
bool bool
fsp_flags_is_valid(ulint flags) fsp_flags_is_valid(ulint flags, bool is_ibd)
{ {
DBUG_EXECUTE_IF("fsp_flags_is_valid_failure", DBUG_EXECUTE_IF("fsp_flags_is_valid_failure",
return(false);); return(false););
...@@ -816,7 +817,7 @@ fsp_flags_is_valid(ulint flags) ...@@ -816,7 +817,7 @@ fsp_flags_is_valid(ulint flags)
bits 10..14 would be nonzero 0bsssaa where sss is bits 10..14 would be nonzero 0bsssaa where sss is
nonzero PAGE_SSIZE (3, 4, 6, or 7) nonzero PAGE_SSIZE (3, 4, 6, or 7)
and aa is ATOMIC_WRITES (not 0b11). */ and aa is ATOMIC_WRITES (not 0b11). */
if (FSP_FLAGS_GET_RESERVED(flags) & ~1) { if (FSP_FLAGS_GET_RESERVED(flags) & ~1U) {
return(false); return(false);
} }
...@@ -839,7 +840,12 @@ fsp_flags_is_valid(ulint flags) ...@@ -839,7 +840,12 @@ fsp_flags_is_valid(ulint flags)
return(false); return(false);
} }
return(true); /* The flags do look valid. But, avoid misinterpreting
buggy MariaDB 10.1 format flags for
PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL={0,2,3}
as valid-looking PAGE_SSIZE if this is known to be
an .ibd file and we are using the default innodb_page_size=16k. */
return(ssize == 0 || !is_ibd || srv_page_size != UNIV_PAGE_SIZE_ORIG);
} }
/** Convert FSP_SPACE_FLAGS from the buggy MariaDB 10.1.0..10.1.20 format. /** Convert FSP_SPACE_FLAGS from the buggy MariaDB 10.1.0..10.1.20 format.
...@@ -948,7 +954,7 @@ fsp_flags_convert_from_101(ulint flags) ...@@ -948,7 +954,7 @@ fsp_flags_convert_from_101(ulint flags)
flags = ((flags & 0x3f) | ssize << FSP_FLAGS_POS_PAGE_SSIZE flags = ((flags & 0x3f) | ssize << FSP_FLAGS_POS_PAGE_SSIZE
| FSP_FLAGS_GET_PAGE_COMPRESSION_MARIADB101(flags) | FSP_FLAGS_GET_PAGE_COMPRESSION_MARIADB101(flags)
<< FSP_FLAGS_POS_PAGE_COMPRESSION); << FSP_FLAGS_POS_PAGE_COMPRESSION);
ut_ad(fsp_flags_is_valid(flags)); ut_ad(fsp_flags_is_valid(flags, false));
return(flags); return(flags);
} }
...@@ -962,7 +968,7 @@ bool ...@@ -962,7 +968,7 @@ bool
fsp_flags_match(ulint expected, ulint actual) fsp_flags_match(ulint expected, ulint actual)
{ {
expected &= ~FSP_FLAGS_MEM_MASK; expected &= ~FSP_FLAGS_MEM_MASK;
ut_ad(fsp_flags_is_valid(expected)); ut_ad(fsp_flags_is_valid(expected, false));
if (actual == expected) { if (actual == expected) {
return(true); return(true);
......
...@@ -548,7 +548,7 @@ AbstractCallback::init( ...@@ -548,7 +548,7 @@ AbstractCallback::init(
const page_t* page = block->frame; const page_t* page = block->frame;
m_space_flags = fsp_header_get_flags(page); m_space_flags = fsp_header_get_flags(page);
if (!fsp_flags_is_valid(m_space_flags)) { if (!fsp_flags_is_valid(m_space_flags, true)) {
ulint cflags = fsp_flags_convert_from_101(m_space_flags); ulint cflags = fsp_flags_convert_from_101(m_space_flags);
if (cflags == ULINT_UNDEFINED) { if (cflags == ULINT_UNDEFINED) {
ib_logf(IB_LOG_LEVEL_ERROR, ib_logf(IB_LOG_LEVEL_ERROR,
......
...@@ -616,7 +616,7 @@ buf_dblwr_process() ...@@ -616,7 +616,7 @@ buf_dblwr_process()
if (page_no == 0) { if (page_no == 0) {
/* Check the FSP_SPACE_FLAGS. */ /* Check the FSP_SPACE_FLAGS. */
ulint flags = fsp_header_get_flags(page); ulint flags = fsp_header_get_flags(page);
if (!fsp_flags_is_valid(flags) if (!fsp_flags_is_valid(flags, space_id)
&& fsp_flags_convert_from_101(flags) && fsp_flags_convert_from_101(flags)
== ULINT_UNDEFINED) { == ULINT_UNDEFINED) {
ib_logf(IB_LOG_LEVEL_WARN, ib_logf(IB_LOG_LEVEL_WARN,
......
...@@ -670,7 +670,7 @@ fil_node_open_file( ...@@ -670,7 +670,7 @@ fil_node_open_file(
ut_free(buf2); ut_free(buf2);
os_file_close(node->handle); os_file_close(node->handle);
if (!fsp_flags_is_valid(flags)) { if (!fsp_flags_is_valid(flags, space->id)) {
ulint cflags = fsp_flags_convert_from_101(flags); ulint cflags = fsp_flags_convert_from_101(flags);
if (cflags == ULINT_UNDEFINED) { if (cflags == ULINT_UNDEFINED) {
ib_logf(IB_LOG_LEVEL_ERROR, ib_logf(IB_LOG_LEVEL_ERROR,
...@@ -2426,7 +2426,7 @@ fil_read_first_page( ...@@ -2426,7 +2426,7 @@ fil_read_first_page(
FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
} }
if (!fsp_flags_is_valid(*flags)) { if (!fsp_flags_is_valid(*flags, *space_id)) {
ulint cflags = fsp_flags_convert_from_101(*flags); ulint cflags = fsp_flags_convert_from_101(*flags);
if (cflags == ULINT_UNDEFINED) { if (cflags == ULINT_UNDEFINED) {
ib_logf(IB_LOG_LEVEL_ERROR, ib_logf(IB_LOG_LEVEL_ERROR,
...@@ -2541,7 +2541,7 @@ fil_op_write_log( ...@@ -2541,7 +2541,7 @@ fil_op_write_log(
ulint len; ulint len;
log_ptr = mlog_open(mtr, 11 + 2 + 1); log_ptr = mlog_open(mtr, 11 + 2 + 1);
ut_ad(fsp_flags_is_valid(flags)); ut_ad(fsp_flags_is_valid(flags, space_id));
if (!log_ptr) { if (!log_ptr) {
/* Logging in mtr is switched off during crash recovery: /* Logging in mtr is switched off during crash recovery:
...@@ -3778,7 +3778,7 @@ fil_create_new_single_table_tablespace( ...@@ -3778,7 +3778,7 @@ fil_create_new_single_table_tablespace(
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
ut_a(space_id < SRV_LOG_SPACE_FIRST_ID); ut_a(space_id < SRV_LOG_SPACE_FIRST_ID);
ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE); ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE);
ut_a(fsp_flags_is_valid(flags & ~FSP_FLAGS_MEM_MASK)); ut_a(fsp_flags_is_valid(flags & ~FSP_FLAGS_MEM_MASK, space_id));
if (is_temp) { if (is_temp) {
/* Temporary table filepath */ /* Temporary table filepath */
...@@ -4172,7 +4172,7 @@ void ...@@ -4172,7 +4172,7 @@ void
fsp_flags_try_adjust(ulint space_id, ulint flags) fsp_flags_try_adjust(ulint space_id, ulint flags)
{ {
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
ut_ad(fsp_flags_is_valid(flags)); ut_ad(fsp_flags_is_valid(flags, space_id));
mtr_t mtr; mtr_t mtr;
mtr_start(&mtr); mtr_start(&mtr);
...@@ -4254,7 +4254,7 @@ fil_open_single_table_tablespace( ...@@ -4254,7 +4254,7 @@ fil_open_single_table_tablespace(
return(DB_CORRUPTION); return(DB_CORRUPTION);
} }
ut_ad(fsp_flags_is_valid(flags & ~FSP_FLAGS_MEM_MASK)); ut_ad(fsp_flags_is_valid(flags & ~FSP_FLAGS_MEM_MASK, id));
atomic_writes = fsp_flags_get_atomic_writes(flags); atomic_writes = fsp_flags_get_atomic_writes(flags);
memset(&def, 0, sizeof(def)); memset(&def, 0, sizeof(def));
...@@ -4795,7 +4795,7 @@ fil_user_tablespace_restore_page( ...@@ -4795,7 +4795,7 @@ fil_user_tablespace_restore_page(
flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page); flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page);
if (!fsp_flags_is_valid(flags)) { if (!fsp_flags_is_valid(flags, fsp->id)) {
ulint cflags = fsp_flags_convert_from_101(flags); ulint cflags = fsp_flags_convert_from_101(flags);
if (cflags == ULINT_UNDEFINED) { if (cflags == ULINT_UNDEFINED) {
ib_logf(IB_LOG_LEVEL_WARN, ib_logf(IB_LOG_LEVEL_WARN,
......
...@@ -664,7 +664,7 @@ fsp_header_init_fields( ...@@ -664,7 +664,7 @@ fsp_header_init_fields(
ulint flags) /*!< in: tablespace flags (FSP_SPACE_FLAGS) */ ulint flags) /*!< in: tablespace flags (FSP_SPACE_FLAGS) */
{ {
flags &= ~FSP_FLAGS_MEM_MASK; flags &= ~FSP_FLAGS_MEM_MASK;
ut_a(fsp_flags_is_valid(flags)); ut_a(fsp_flags_is_valid(flags, space_id));
mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page, mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page,
space_id); space_id);
......
...@@ -934,7 +934,7 @@ dict_tf_to_fsp_flags( ...@@ -934,7 +934,7 @@ dict_tf_to_fsp_flags(
fsp_flags |= FSP_FLAGS_MASK_PAGE_COMPRESSION; fsp_flags |= FSP_FLAGS_MASK_PAGE_COMPRESSION;
} }
ut_a(fsp_flags_is_valid(fsp_flags)); ut_a(fsp_flags_is_valid(fsp_flags, false));
if (DICT_TF_HAS_DATA_DIR(table_flags)) { if (DICT_TF_HAS_DATA_DIR(table_flags)) {
fsp_flags |= 1U << FSP_FLAGS_MEM_DATA_DIR; fsp_flags |= 1U << FSP_FLAGS_MEM_DATA_DIR;
......
...@@ -787,11 +787,12 @@ fseg_print( ...@@ -787,11 +787,12 @@ fseg_print(
/** Validate the tablespace flags, which are stored in the /** Validate the tablespace flags, which are stored in the
tablespace header at offset FSP_SPACE_FLAGS. tablespace header at offset FSP_SPACE_FLAGS.
@param[in] flags the contents of FSP_SPACE_FLAGS @param[in] flags the contents of FSP_SPACE_FLAGS
@param[in] is_ibd whether this is an .ibd file (not system tablespace)
@return whether the flags are correct (not in the buggy 10.1) format */ @return whether the flags are correct (not in the buggy 10.1) format */
MY_ATTRIBUTE((warn_unused_result, const)) MY_ATTRIBUTE((warn_unused_result, const))
UNIV_INLINE UNIV_INLINE
bool bool
fsp_flags_is_valid(ulint flags) fsp_flags_is_valid(ulint flags, bool is_ibd)
{ {
DBUG_EXECUTE_IF("fsp_flags_is_valid_failure", DBUG_EXECUTE_IF("fsp_flags_is_valid_failure",
return(false);); return(false););
...@@ -815,7 +816,7 @@ fsp_flags_is_valid(ulint flags) ...@@ -815,7 +816,7 @@ fsp_flags_is_valid(ulint flags)
bits 10..14 would be nonzero 0bsssaa where sss is bits 10..14 would be nonzero 0bsssaa where sss is
nonzero PAGE_SSIZE (3, 4, 6, or 7) nonzero PAGE_SSIZE (3, 4, 6, or 7)
and aa is ATOMIC_WRITES (not 0b11). */ and aa is ATOMIC_WRITES (not 0b11). */
if (FSP_FLAGS_GET_RESERVED(flags) & ~1) { if (FSP_FLAGS_GET_RESERVED(flags) & ~1U) {
return(false); return(false);
} }
...@@ -838,7 +839,12 @@ fsp_flags_is_valid(ulint flags) ...@@ -838,7 +839,12 @@ fsp_flags_is_valid(ulint flags)
return(false); return(false);
} }
return(true); /* The flags do look valid. But, avoid misinterpreting
buggy MariaDB 10.1 format flags for
PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL={0,2,3}
as valid-looking PAGE_SSIZE if this is known to be
an .ibd file and we are using the default innodb_page_size=16k. */
return(ssize == 0 || !is_ibd || srv_page_size != UNIV_PAGE_SIZE_ORIG);
} }
/** Convert FSP_SPACE_FLAGS from the buggy MariaDB 10.1.0..10.1.20 format. /** Convert FSP_SPACE_FLAGS from the buggy MariaDB 10.1.0..10.1.20 format.
...@@ -947,7 +953,7 @@ fsp_flags_convert_from_101(ulint flags) ...@@ -947,7 +953,7 @@ fsp_flags_convert_from_101(ulint flags)
flags = ((flags & 0x3f) | ssize << FSP_FLAGS_POS_PAGE_SSIZE flags = ((flags & 0x3f) | ssize << FSP_FLAGS_POS_PAGE_SSIZE
| FSP_FLAGS_GET_PAGE_COMPRESSION_MARIADB101(flags) | FSP_FLAGS_GET_PAGE_COMPRESSION_MARIADB101(flags)
<< FSP_FLAGS_POS_PAGE_COMPRESSION); << FSP_FLAGS_POS_PAGE_COMPRESSION);
ut_ad(fsp_flags_is_valid(flags)); ut_ad(fsp_flags_is_valid(flags, false));
return(flags); return(flags);
} }
...@@ -961,7 +967,7 @@ bool ...@@ -961,7 +967,7 @@ bool
fsp_flags_match(ulint expected, ulint actual) fsp_flags_match(ulint expected, ulint actual)
{ {
expected &= ~FSP_FLAGS_MEM_MASK; expected &= ~FSP_FLAGS_MEM_MASK;
ut_ad(fsp_flags_is_valid(expected)); ut_ad(fsp_flags_is_valid(expected, false));
if (actual == expected) { if (actual == expected) {
return(true); return(true);
......
...@@ -549,7 +549,7 @@ AbstractCallback::init( ...@@ -549,7 +549,7 @@ AbstractCallback::init(
const page_t* page = block->frame; const page_t* page = block->frame;
m_space_flags = fsp_header_get_flags(page); m_space_flags = fsp_header_get_flags(page);
if (!fsp_flags_is_valid(m_space_flags)) { if (!fsp_flags_is_valid(m_space_flags, true)) {
ulint cflags = fsp_flags_convert_from_101(m_space_flags); ulint cflags = fsp_flags_convert_from_101(m_space_flags);
if (cflags == ULINT_UNDEFINED) { if (cflags == ULINT_UNDEFINED) {
ib_logf(IB_LOG_LEVEL_ERROR, ib_logf(IB_LOG_LEVEL_ERROR,
......
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