Commit 6a524fcf authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-14140 IMPORT TABLESPACE must not go beyond FSP_FREE_LIMIT

ibuf_check_bitmap_on_import(): Only access the pages that
are below FSP_FREE_LIMIT. It is possible that especially with
ROW_FORMAT=COMPRESSED, the FSP_SIZE will be much bigger than
the FSP_FREE_LIMIT, and the bitmap pages (page_size*N, 1+page_size*N)
are filled with zero bytes.

buf_page_is_corrupted(), buf_page_io_complete(): Make the
fault injection compatible with MariaDB 10.2.

Backport the IMPORT tests from 10.2.
parent bfde65c0
......@@ -577,6 +577,8 @@ buf_page_is_corrupted(
ulint zip_size) /*!< in: size of compressed page;
0 for uncompressed pages */
{
DBUG_EXECUTE_IF("buf_page_import_corrupt_failure", return(TRUE); );
ulint checksum_field1;
ulint checksum_field2;
......@@ -658,8 +660,6 @@ buf_page_is_corrupted(
return(FALSE);
}
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); );
ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET);
ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_SPACE_ID);
const srv_checksum_algorithm_t curr_algo =
......@@ -4216,7 +4216,7 @@ buf_page_io_complete(
/* Not a real corruption if it was triggered by
error injection */
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure",
DBUG_EXECUTE_IF("buf_page_import_corrupt_failure",
if (bpage->space > TRX_SYS_SPACE
&& buf_mark_space_corrupt(bpage)) {
ib_logf(IB_LOG_LEVEL_INFO,
......@@ -4279,7 +4279,7 @@ buf_page_io_complete(
}
}
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure",
DBUG_EXECUTE_IF("buf_page_import_corrupt_failure",
page_not_corrupt: bpage = bpage; );
if (recv_recovery_is_on()) {
......
......@@ -5099,7 +5099,20 @@ ibuf_check_bitmap_on_import(
return(DB_TABLE_NOT_FOUND);
}
size = fil_space_get_size(space_id);
mtr_t mtr;
mtr_start(&mtr);
{
buf_block_t* sp = buf_page_get(space_id, zip_size, 0,
RW_S_LATCH, &mtr);
if (sp) {
size = mach_read_from_4(
FSP_HEADER_OFFSET + FSP_FREE_LIMIT
+ sp->frame);
} else {
size = 0;
}
}
mtr_commit(&mtr);
if (size == 0) {
return(DB_TABLE_NOT_FOUND);
......@@ -5110,7 +5123,6 @@ ibuf_check_bitmap_on_import(
page_size = zip_size ? zip_size : UNIV_PAGE_SIZE;
for (page_no = 0; page_no < size; page_no += page_size) {
mtr_t mtr;
page_t* bitmap_page;
ulint i;
......
......@@ -646,6 +646,8 @@ buf_page_is_corrupted(
ulint zip_size) /*!< in: size of compressed page;
0 for uncompressed pages */
{
DBUG_EXECUTE_IF("buf_page_import_corrupt_failure", return(TRUE); );
ulint checksum_field1;
ulint checksum_field2;
......@@ -727,8 +729,6 @@ buf_page_is_corrupted(
return(FALSE);
}
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); );
ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET);
ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_SPACE_ID);
const srv_checksum_algorithm_t curr_algo =
......@@ -4421,7 +4421,7 @@ buf_page_io_complete(
/* Not a real corruption if it was triggered by
error injection */
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure",
DBUG_EXECUTE_IF("buf_page_import_corrupt_failure",
if (bpage->space > TRX_SYS_SPACE
&& buf_mark_space_corrupt(bpage)) {
ib_logf(IB_LOG_LEVEL_INFO,
......@@ -4502,7 +4502,7 @@ buf_page_io_complete(
}
} /**/
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure",
DBUG_EXECUTE_IF("buf_page_import_corrupt_failure",
page_not_corrupt: bpage = bpage; );
if (recv_recovery_is_on()) {
......
......@@ -5141,7 +5141,20 @@ ibuf_check_bitmap_on_import(
return(DB_TABLE_NOT_FOUND);
}
size = fil_space_get_size(space_id);
mtr_t mtr;
mtr_start(&mtr);
{
buf_block_t* sp = buf_page_get(space_id, zip_size, 0,
RW_S_LATCH, &mtr);
if (sp) {
size = mach_read_from_4(
FSP_HEADER_OFFSET + FSP_FREE_LIMIT
+ sp->frame);
} else {
size = 0;
}
}
mtr_commit(&mtr);
if (size == 0) {
return(DB_TABLE_NOT_FOUND);
......@@ -5152,7 +5165,6 @@ ibuf_check_bitmap_on_import(
page_size = zip_size ? zip_size : UNIV_PAGE_SIZE;
for (page_no = 0; page_no < size; page_no += page_size) {
mtr_t mtr;
page_t* bitmap_page;
ulint i;
......
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