diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-02 14:49:53 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-06 21:25:43 +0300 |
commit | 45d338dca89dcf66fc6fe224ce1e00401d2c9bd0 (patch) | |
tree | 0af4c6156ba5ab436c3526a197325d843aa2ada0 | |
parent | 1b95118c5f60c216f8f5ed342b981e48522889b8 (diff) | |
download | mariadb-git-45d338dca89dcf66fc6fe224ce1e00401d2c9bd0.tar.gz |
MDEV-12699 preparation: Initialize the entire page on MLOG_ZIP_PAGE_COMPRESS
The record MLOG_ZIP_PAGE_COMPRESS is similar to MLOG_INIT_FILE_PAGE2
that it contains all the information needed to initialize the page.
Like for the other record, do initialize the entire page on recovery.
-rw-r--r-- | storage/innobase/include/page0zip.h | 20 | ||||
-rw-r--r-- | storage/innobase/log/log0recv.cc | 2 | ||||
-rw-r--r-- | storage/innobase/page/page0zip.cc | 35 |
3 files changed, 30 insertions, 27 deletions
diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index f458b29c4b4..28a7a3a6b8c 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -2,7 +2,7 @@ Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -475,16 +475,14 @@ page_zip_copy_recs( dict_index_t* index, /*!< in: index of the B-tree */ mtr_t* mtr); /*!< in: mini-transaction */ -/**********************************************************************//** -Parses a log record of compressing an index page. -@return end of log record or NULL */ -byte* -page_zip_parse_compress( -/*====================*/ - byte* ptr, /*!< in: buffer */ - byte* end_ptr, /*!< in: buffer end */ - page_t* page, /*!< out: uncompressed page */ - page_zip_des_t* page_zip); /*!< out: compressed page */ +/** Parse and optionally apply MLOG_ZIP_PAGE_COMPRESS. +@param[in] ptr log record +@param[in] end_ptr end of log +@param[in,out] block ROW_FORMAT=COMPRESSED block, or NULL for parsing only +@return end of log record +@retval NULL if the log record is incomplete */ +byte* page_zip_parse_compress(const byte* ptr, const byte* end_ptr, + buf_block_t* block); #endif /* !UNIV_INNOCHECKSUM */ diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index a6b42e6c66d..b6b10072081 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1690,7 +1690,7 @@ parse_log: break; case MLOG_ZIP_PAGE_COMPRESS: /* Allow anything in page_type when creating a page. */ - ptr = page_zip_parse_compress(ptr, end_ptr, page, page_zip); + ptr = page_zip_parse_compress(ptr, end_ptr, block); break; case MLOG_ZIP_PAGE_COMPRESS_NO_DATA: if (NULL != (ptr = mlog_parse_index( diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 001d33662d1..d525b008fcd 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -4846,23 +4846,20 @@ page_zip_copy_recs( page_zip_compress_write_log(page_zip, page, index, mtr); } -/**********************************************************************//** -Parses a log record of compressing an index page. -@return end of log record or NULL */ -byte* -page_zip_parse_compress( -/*====================*/ - byte* ptr, /*!< in: buffer */ - byte* end_ptr,/*!< in: buffer end */ - page_t* page, /*!< out: uncompressed page */ - page_zip_des_t* page_zip)/*!< out: compressed page */ +/** Parse and optionally apply MLOG_ZIP_PAGE_COMPRESS. +@param[in] ptr log record +@param[in] end_ptr end of log +@param[in,out] block ROW_FORMAT=COMPRESSED block, or NULL for parsing only +@return end of log record +@retval NULL if the log record is incomplete */ +byte* page_zip_parse_compress(const byte* ptr, const byte* end_ptr, + buf_block_t* block) { ulint size; ulint trailer_size; ut_ad(ptr != NULL); ut_ad(end_ptr!= NULL); - ut_ad(!page == !page_zip); if (UNIV_UNLIKELY(ptr + (2 + 2) > end_ptr)) { @@ -4879,14 +4876,22 @@ page_zip_parse_compress( return(NULL); } - if (page) { - if (!page_zip || page_zip_get_size(page_zip) < size) { + if (block) { + ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); + page_zip_des_t* page_zip = buf_block_get_page_zip(block); + if (!page_zip || page_zip_get_size(page_zip) < size + || block->page.id.page_no() < 3) { corrupt: recv_sys->found_corrupt_log = TRUE; return(NULL); } + memset(page_zip->data, 0, page_zip_get_size(page_zip)); + mach_write_to_4(FIL_PAGE_OFFSET + + page_zip->data, block->page.id.page_no()); + mach_write_to_4(FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID + + page_zip->data, block->page.id.space()); memcpy(page_zip->data + FIL_PAGE_PREV, ptr, 4); memcpy(page_zip->data + FIL_PAGE_NEXT, ptr + 4, 4); memcpy(page_zip->data + FIL_PAGE_TYPE, ptr + 8, size); @@ -4896,14 +4901,14 @@ corrupt: memcpy(page_zip->data + page_zip_get_size(page_zip) - trailer_size, ptr + 8 + size, trailer_size); - if (UNIV_UNLIKELY(!page_zip_decompress(page_zip, page, + if (UNIV_UNLIKELY(!page_zip_decompress(page_zip, block->frame, TRUE))) { goto corrupt; } } - return(ptr + 8 + size + trailer_size); + return(const_cast<byte*>(ptr) + 8 + size + trailer_size); } #endif /* !UNIV_INNOCHECKSUM */ |