mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
MDEV-28679 After upgrade to 10.7.3-1 with enabled data-at-rest encryption unable to restore dump file.
- InnoDB bulk insert fails to use encryption buffer for encrypting the temporary log file. Declare the m_crypt_block, m_crypt_pfx in row_merge_bulk_t to be used for encrypting the temporary file.
This commit is contained in:
parent
3808ffbcb5
commit
19283c67c6
5 changed files with 41 additions and 5 deletions
7
mysql-test/suite/encryption/r/bulk_insert.result
Normal file
7
mysql-test/suite/encryption/r/bulk_insert.result
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
SET UNIQUE_CHECKS=0, FOREIGN_KEY_CHECKS=0;
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
`id` int(10) unsigned NOT NULL,
|
||||||
|
UNIQUE KEY `id` (`id`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 SELECT seq FROM seq_1_to_65536;
|
||||||
|
DROP TABLE t1;
|
1
mysql-test/suite/encryption/t/bulk_insert.opt
Normal file
1
mysql-test/suite/encryption/t/bulk_insert.opt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
--innodb_encrypt_log=1
|
11
mysql-test/suite/encryption/t/bulk_insert.test
Normal file
11
mysql-test/suite/encryption/t/bulk_insert.test
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
--source include/have_innodb.inc
|
||||||
|
--source include/have_sequence.inc
|
||||||
|
--source include/have_file_key_management_plugin.inc
|
||||||
|
|
||||||
|
SET UNIQUE_CHECKS=0, FOREIGN_KEY_CHECKS=0;
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
`id` int(10) unsigned NOT NULL,
|
||||||
|
UNIQUE KEY `id` (`id`)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 SELECT seq FROM seq_1_to_65536;
|
||||||
|
DROP TABLE t1;
|
|
@ -429,6 +429,10 @@ class row_merge_bulk_t
|
||||||
ut_new_pfx_t m_block_pfx;
|
ut_new_pfx_t m_block_pfx;
|
||||||
/** Temporary file to store the blob */
|
/** Temporary file to store the blob */
|
||||||
merge_file_t m_blob_file;
|
merge_file_t m_blob_file;
|
||||||
|
/** Storage for description for the crypt_block */
|
||||||
|
ut_new_pfx_t m_crypt_pfx;
|
||||||
|
/** Block for encryption */
|
||||||
|
row_merge_block_t *m_crypt_block= nullptr;
|
||||||
public:
|
public:
|
||||||
/** Constructor.
|
/** Constructor.
|
||||||
Create all merge files, merge buffer for all the table indexes
|
Create all merge files, merge buffer for all the table indexes
|
||||||
|
|
|
@ -1265,7 +1265,7 @@ row_merge_read(
|
||||||
if (success && log_tmp_is_encrypted()) {
|
if (success && log_tmp_is_encrypted()) {
|
||||||
if (!log_tmp_block_decrypt(buf, srv_sort_buf_size,
|
if (!log_tmp_block_decrypt(buf, srv_sort_buf_size,
|
||||||
crypt_buf, ofs)) {
|
crypt_buf, ofs)) {
|
||||||
return (FALSE);
|
DBUG_RETURN(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
srv_stats.n_merge_blocks_decrypted.inc();
|
srv_stats.n_merge_blocks_decrypted.inc();
|
||||||
|
@ -1312,7 +1312,7 @@ row_merge_write(
|
||||||
buf_len,
|
buf_len,
|
||||||
static_cast<byte*>(crypt_buf),
|
static_cast<byte*>(crypt_buf),
|
||||||
ofs)) {
|
ofs)) {
|
||||||
return false;
|
DBUG_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
srv_stats.n_merge_blocks_encrypted.inc();
|
srv_stats.n_merge_blocks_encrypted.inc();
|
||||||
|
@ -5068,6 +5068,16 @@ dberr_t row_merge_bulk_t::alloc_block()
|
||||||
3 * srv_sort_buf_size, &m_block_pfx);
|
3 * srv_sort_buf_size, &m_block_pfx);
|
||||||
if (m_block == nullptr)
|
if (m_block == nullptr)
|
||||||
return DB_OUT_OF_MEMORY;
|
return DB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
m_crypt_pfx.m_size= 0;
|
||||||
|
TRASH_ALLOC(&m_crypt_pfx, sizeof m_crypt_pfx);
|
||||||
|
if (log_tmp_is_encrypted())
|
||||||
|
{
|
||||||
|
m_crypt_block= static_cast<row_merge_block_t*>(
|
||||||
|
m_alloc.allocate_large(3 * srv_sort_buf_size, &m_crypt_pfx));
|
||||||
|
if (!m_crypt_block)
|
||||||
|
return DB_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
return DB_SUCCESS;
|
return DB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5128,6 +5138,9 @@ row_merge_bulk_t::~row_merge_bulk_t()
|
||||||
|
|
||||||
if (m_block)
|
if (m_block)
|
||||||
m_alloc.deallocate_large(m_block, &m_block_pfx);
|
m_alloc.deallocate_large(m_block, &m_block_pfx);
|
||||||
|
|
||||||
|
if (m_crypt_block)
|
||||||
|
m_alloc.deallocate_large(m_crypt_block, &m_crypt_pfx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void row_merge_bulk_t::init_tmp_file()
|
void row_merge_bulk_t::init_tmp_file()
|
||||||
|
@ -5187,7 +5200,7 @@ dberr_t row_merge_bulk_t::write_to_tmp_file(ulint index_no)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (!row_merge_write(file->fd, file->offset++,
|
if (!row_merge_write(file->fd, file->offset++,
|
||||||
m_block, nullptr,
|
m_block, m_crypt_block,
|
||||||
buf->index->table->space->id))
|
buf->index->table->space->id))
|
||||||
return DB_TEMP_FILE_WRITE_FAIL;
|
return DB_TEMP_FILE_WRITE_FAIL;
|
||||||
MEM_UNDEFINED(&m_block[0], srv_sort_buf_size);
|
MEM_UNDEFINED(&m_block[0], srv_sort_buf_size);
|
||||||
|
@ -5308,13 +5321,13 @@ dberr_t row_merge_bulk_t::write_to_index(ulint index_no, trx_t *trx)
|
||||||
|
|
||||||
err= row_merge_sort(trx, &dup, file,
|
err= row_merge_sort(trx, &dup, file,
|
||||||
m_block, &m_tmpfd, true, 0, 0,
|
m_block, &m_tmpfd, true, 0, 0,
|
||||||
nullptr, table->space_id, nullptr);
|
m_crypt_block, table->space_id, nullptr);
|
||||||
if (err != DB_SUCCESS)
|
if (err != DB_SUCCESS)
|
||||||
goto func_exit;
|
goto func_exit;
|
||||||
|
|
||||||
err= row_merge_insert_index_tuples(
|
err= row_merge_insert_index_tuples(
|
||||||
index, table, file->fd, m_block, nullptr,
|
index, table, file->fd, m_block, nullptr,
|
||||||
&btr_bulk, 0, 0, 0, nullptr, table->space_id,
|
&btr_bulk, 0, 0, 0, m_crypt_block, table->space_id,
|
||||||
nullptr, &m_blob_file);
|
nullptr, &m_blob_file);
|
||||||
|
|
||||||
func_exit:
|
func_exit:
|
||||||
|
|
Loading…
Add table
Reference in a new issue