Skip to content

Commit 7573fe8

Browse files
MDEV-32968 InnoDB fails to restore tablespace first page from doublewrite 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
1 parent c95ba18 commit 7573fe8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

mysql-test/suite/innodb/t/doublewrite.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ commit work;
3939
SET GLOBAL innodb_fast_shutdown = 0;
4040
let $shutdown_timeout=;
4141
--source include/restart_mysqld.inc
42+
# Ensure that buf_flush_page_cleaner() has woken up from its
43+
# first my_cond_timedwait() and gone idle.
44+
sleep 1;
4245
--source ../include/no_checkpoint_start.inc
4346
connect (dml,localhost,root,,);
4447
XA START 'x';

storage/innobase/log/log0recv.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3871,16 +3871,20 @@ uint32_t recv_dblwr_t::find_first_page(const char *name, pfs_os_file_t file)
38713871
for (const page_t *page : pages)
38723872
{
38733873
uint32_t space_id= page_get_space_id(page);
3874+
byte *read_page= nullptr;
38743875
if (page_get_page_no(page) > 0 || space_id == 0)
3876+
{
38753877
next_page:
3878+
aligned_free(read_page);
38763879
continue;
3880+
}
38773881
uint32_t flags= mach_read_from_4(
38783882
FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page);
38793883
page_id_t page_id(space_id, 0);
38803884
size_t page_size= fil_space_t::physical_size(flags);
38813885
if (file_size < 4 * page_size)
38823886
goto next_page;
3883-
byte *read_page=
3887+
read_page=
38843888
static_cast<byte*>(aligned_malloc(3 * page_size, page_size));
38853889
/* Read 3 pages from the file and match the space id
38863890
with the space id which is stored in
@@ -3892,15 +3896,22 @@ uint32_t recv_dblwr_t::find_first_page(const char *name, pfs_os_file_t file)
38923896
{
38933897
byte *cur_page= read_page + j * page_size;
38943898
if (buf_is_zeroes(span<const byte>(cur_page, page_size)))
3895-
return 0;
3899+
{
3900+
space_id= 0;
3901+
goto early_exit;
3902+
}
38963903
if (mach_read_from_4(cur_page + FIL_PAGE_OFFSET) != j + 1 ||
38973904
memcmp(cur_page + FIL_PAGE_SPACE_ID,
38983905
page + FIL_PAGE_SPACE_ID, 4) ||
38993906
buf_page_is_corrupted(false, cur_page, flags))
39003907
goto next_page;
39013908
}
39023909
if (!restore_first_page(space_id, name, file))
3910+
{
3911+
early_exit:
3912+
aligned_free(read_page);
39033913
return space_id;
3914+
}
39043915
break;
39053916
}
39063917
}

0 commit comments

Comments
 (0)