Skip to content

Commit

Permalink
MDEV-32968 InnoDB fails to restore tablespace first page from doublew…
Browse files Browse the repository at this point in the history
…rite buffer when page is empty

recv_dblwr_t::find_first_page(): Free the allocated memory
to read the first 3 pages from tablespace.

innodb.doublewrite: Added sleep to ensure page cleaner thread
wake up from my_cond_wait
  • Loading branch information
Thirunarayanan committed Jan 19, 2024
1 parent c95ba18 commit 7573fe8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions mysql-test/suite/innodb/t/doublewrite.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ commit work;
SET GLOBAL innodb_fast_shutdown = 0;
let $shutdown_timeout=;
--source include/restart_mysqld.inc
# Ensure that buf_flush_page_cleaner() has woken up from its
# first my_cond_timedwait() and gone idle.
sleep 1;
--source ../include/no_checkpoint_start.inc
connect (dml,localhost,root,,);
XA START 'x';
Expand Down
15 changes: 13 additions & 2 deletions storage/innobase/log/log0recv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3871,16 +3871,20 @@ uint32_t recv_dblwr_t::find_first_page(const char *name, pfs_os_file_t file)
for (const page_t *page : pages)
{
uint32_t space_id= page_get_space_id(page);
byte *read_page= nullptr;
if (page_get_page_no(page) > 0 || space_id == 0)
{
next_page:
aligned_free(read_page);
continue;
}
uint32_t flags= mach_read_from_4(
FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page);
page_id_t page_id(space_id, 0);
size_t page_size= fil_space_t::physical_size(flags);
if (file_size < 4 * page_size)
goto next_page;
byte *read_page=
read_page=
static_cast<byte*>(aligned_malloc(3 * page_size, page_size));
/* Read 3 pages from the file and match the space id
with the space id which is stored in
Expand All @@ -3892,15 +3896,22 @@ uint32_t recv_dblwr_t::find_first_page(const char *name, pfs_os_file_t file)
{
byte *cur_page= read_page + j * page_size;
if (buf_is_zeroes(span<const byte>(cur_page, page_size)))
return 0;
{
space_id= 0;
goto early_exit;
}
if (mach_read_from_4(cur_page + FIL_PAGE_OFFSET) != j + 1 ||
memcmp(cur_page + FIL_PAGE_SPACE_ID,
page + FIL_PAGE_SPACE_ID, 4) ||
buf_page_is_corrupted(false, cur_page, flags))
goto next_page;
}
if (!restore_first_page(space_id, name, file))
{
early_exit:
aligned_free(read_page);
return space_id;
}
break;
}
}
Expand Down

0 comments on commit 7573fe8

Please sign in to comment.