MDEV-31098 InnoDB Recovery doesn't display encryption message when no...

MDEV-31098  InnoDB Recovery doesn't display encryption message when no encryption configuration passed

- InnoDB fails to report the error when encryption configuration
wasn't passed. This patch addresses the issue by adding
the error while loading the tablespace and deferring the
tablespace creation.
parent 8bf17c57
......@@ -9,6 +9,7 @@ call mtr.add_suppression("InnoDB: Cannot apply log to \\[page id: space=[1-9][0-
call mtr.add_suppression("InnoDB: Failed to read page .* from file '.*'");
call mtr.add_suppression("InnoDB: OPT_PAGE_CHECKSUM mismatch");
call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore corruption");
call mtr.add_suppression("InnoDB: Encryption key is not found for");
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
SET GLOBAL innodb_file_per_table = ON;
create table t1(a int not null primary key auto_increment, c char(200), b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes encryption_key_id=20;
......@@ -39,5 +40,6 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
FOUND 1 /\[ERROR\] InnoDB: Encryption key is not found for .*test.t1.ibd/ in mysqld.1.err
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
drop table t1,t2,t3,t4,t5;
......@@ -14,6 +14,7 @@ call mtr.add_suppression("InnoDB: Cannot apply log to \\[page id: space=[1-9][0-
call mtr.add_suppression("InnoDB: Failed to read page .* from file '.*'");
call mtr.add_suppression("InnoDB: OPT_PAGE_CHECKSUM mismatch");
call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore corruption");
call mtr.add_suppression("InnoDB: Encryption key is not found for");
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
-- source include/restart_mysqld.inc
......@@ -73,6 +74,10 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');
let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_PATTERN = \[ERROR\] InnoDB: Encryption key is not found for .*test.t1.ibd;
--source include/search_pattern_in_file.inc
#
# In above server does start but InnoDB refuses to start
# thus we need to restart server with correct key file
......
......@@ -2428,6 +2428,17 @@ fil_ibd_discover(
/* A datafile was not discovered for the filename given. */
return(false);
}
bool fil_crypt_check(fil_space_crypt_t *crypt_data, const char *f_name)
{
if (crypt_data->is_key_found())
return true;
sql_print_error("InnoDB: Encryption key is not found for %s", f_name);
crypt_data->~fil_space_crypt_t();
ut_free(crypt_data);
return false;
}
/** Open an ibd tablespace and add it to the InnoDB data structures.
This is similar to fil_ibd_open() except that it is used while processing
the REDO log, so the data dictionary is not available and very little
......@@ -2576,9 +2587,7 @@ fil_ibd_load(
first_page)
: NULL;
if (crypt_data && !crypt_data->is_key_found()) {
crypt_data->~fil_space_crypt_t();
ut_free(crypt_data);
if (crypt_data && !fil_crypt_check(crypt_data, filename)) {
return FIL_LOAD_INVALID;
}
......
......@@ -1946,4 +1946,10 @@ void test_make_filepath();
@return block size */
ulint fil_space_get_block_size(const fil_space_t* space, unsigned offset);
/** Check whether encryption key found
@param crypt_data Encryption data
@param f_name File name
@return encryption key found */
bool fil_crypt_check(fil_space_crypt_t *crypt_data, const char *f_name);
#endif /* UNIV_INNOCHECKSUM */
......@@ -827,12 +827,8 @@ static struct
const std::string &name, uint32_t flags,
fil_space_crypt_t *crypt_data, uint32_t size)
{
if (crypt_data && !crypt_data->is_key_found())
{
crypt_data->~fil_space_crypt_t();
ut_free(crypt_data);
if (crypt_data && !fil_crypt_check(crypt_data, name.c_str()))
return nullptr;
}
mysql_mutex_lock(&fil_system.mutex);
fil_space_t *space= fil_space_t::create(it->first, flags,
FIL_TYPE_TABLESPACE, crypt_data);
......
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