From 95da2113a050ad739fdaf60ee871329468a01554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Mar 2020 13:14:05 +0200 Subject: [PATCH] MDEV-21549 IMPORT TABLESPACE fails to adjust all tablespace ID After MDEV-12353, the consistency check that I originally added for commit 1b9fe0bbac72d49a32863241b2b5081438b5f691 (InnoDB Plugin for MySQL 5.1) started randomly failing. It turns out that the IMPORT TABLESPACE code was always incorrect: it did not update the (redundantly stored) tablespace ID in index tree root pages. It only does that for page headers and BLOB pointers. PageConverter::update_index_page(): Update the tablespace ID in the BTR_SEG_TOP and BTR_SEG_LEAF of index root pages. --- storage/innobase/row/row0import.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 494a8b3b729..3c5e27f5b27 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -1913,6 +1913,23 @@ PageConverter::update_index_page( return(DB_SUCCESS); } + if (m_index && block->page.id.page_no() == m_index->m_page_no) { + byte *b = FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF + FSEG_HDR_SPACE + + page; + mach_write_to_4(b, block->page.id.space()); + + memcpy(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP + FSEG_HDR_SPACE + + page, b, 4); + if (UNIV_LIKELY_NULL(block->page.zip.data)) { + memcpy(&block->page.zip.data[FIL_PAGE_DATA + + PAGE_BTR_SEG_TOP + + FSEG_HDR_SPACE], b, 4); + memcpy(&block->page.zip.data[FIL_PAGE_DATA + + PAGE_BTR_SEG_LEAF + + FSEG_HDR_SPACE], b, 4); + } + } + #ifdef UNIV_ZIP_DEBUG ut_a(!block->page.zip.data || page_zip_validate(&block->page.zip, page, m_index->m_srv_index));