diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-05-13 11:41:22 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-05-14 11:32:24 +0300 |
commit | f8cacd03a79e56746434f7c12e2ed8dd6a534b8e (patch) | |
tree | 884b1bfe12b66524df14df4fd16e0eac048edfe7 /storage/innobase/include/fil0fil.ic | |
parent | be2038e3cb2f37504cc2094e79beb8b1d33bc69e (diff) | |
download | mariadb-git-f8cacd03a79e56746434f7c12e2ed8dd6a534b8e.tar.gz |
MDEV-8143: InnoDB: Database page corruption on disk or a failed file read
Analysis: Problem was that we did create crypt data for encrypted table but
this new crypt data was not written to page 0. Instead a default crypt data
was written to page 0 at table creation.
Fixed by explicitly writing new crypt data to page 0 after successfull
table creation.
Diffstat (limited to 'storage/innobase/include/fil0fil.ic')
-rw-r--r-- | storage/innobase/include/fil0fil.ic | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/storage/innobase/include/fil0fil.ic b/storage/innobase/include/fil0fil.ic index b1e65e6dddb..6ec7c1adec8 100644 --- a/storage/innobase/include/fil0fil.ic +++ b/storage/innobase/include/fil0fil.ic @@ -105,4 +105,70 @@ fil_node_get_block_size( return (node->file_block_size); } +#ifdef UNIV_DEBUG +/****************************************************************//** +Validate page type. +@return true if valid, false if not */ +UNIV_INLINE +bool +fil_page_type_validate( + const byte* page) /*!< in: page */ +{ + ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE); +#ifdef UNIV_ENCRYPTION_EXTRA_DEBUG + uint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); + bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED); + ulint space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); + ulint offset = mach_read_from_4(page + FIL_PAGE_OFFSET); + ib_uint64_t lsn = mach_read_from_8(page + FIL_PAGE_LSN); + ulint compressed_len = mach_read_from_2(page + FIL_PAGE_DATA); + fil_system_enter(); + fil_space_t* rspace = fil_space_get_by_id(space); + fil_system_exit(); + + /* Dump out the page info */ + fprintf(stderr, "InnoDB: Space %lu offset %lu name %s page_type %lu page_type_name %s\n" + "InnoDB: key_version %u page_compressed %d lsn %lu compressed_len %lu\n", + space, offset, rspace->name, page_type, fil_get_page_type_name(page_type), + key_version, page_compressed, lsn, compressed_len); + fflush(stderr); +#endif + + /* Validate page type */ + if (!((page_type == FIL_PAGE_PAGE_COMPRESSED || + page_type == FIL_PAGE_INDEX || + page_type == FIL_PAGE_UNDO_LOG || + page_type == FIL_PAGE_INODE || + page_type == FIL_PAGE_IBUF_FREE_LIST || + page_type == FIL_PAGE_TYPE_ALLOCATED || + page_type == FIL_PAGE_IBUF_BITMAP || + page_type == FIL_PAGE_TYPE_SYS || + page_type == FIL_PAGE_TYPE_TRX_SYS || + page_type == FIL_PAGE_TYPE_FSP_HDR || + page_type == FIL_PAGE_TYPE_XDES || + page_type == FIL_PAGE_TYPE_BLOB || + page_type == FIL_PAGE_TYPE_ZBLOB || + page_type == FIL_PAGE_TYPE_COMPRESSED))) { + + ut_ad(page_type == FIL_PAGE_PAGE_COMPRESSED || + page_type == FIL_PAGE_INDEX || + page_type == FIL_PAGE_UNDO_LOG || + page_type == FIL_PAGE_INODE || + page_type == FIL_PAGE_IBUF_FREE_LIST || + page_type == FIL_PAGE_TYPE_ALLOCATED || + page_type == FIL_PAGE_IBUF_BITMAP || + page_type == FIL_PAGE_TYPE_SYS || + page_type == FIL_PAGE_TYPE_TRX_SYS || + page_type == FIL_PAGE_TYPE_FSP_HDR || + page_type == FIL_PAGE_TYPE_XDES || + page_type == FIL_PAGE_TYPE_BLOB || + page_type == FIL_PAGE_TYPE_ZBLOB || + page_type == FIL_PAGE_TYPE_COMPRESSED); + return false; + } + + return true; +} +#endif /* UNIV_DEBUG */ + #endif /* fil0fil_ic */ |