Commit 45d338dc authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 1b95118c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -475,16 +475,14 @@ page_zip_copy_recs( ...@@ -475,16 +475,14 @@ page_zip_copy_recs(
dict_index_t* index, /*!< in: index of the B-tree */ dict_index_t* index, /*!< in: index of the B-tree */
mtr_t* mtr); /*!< in: mini-transaction */ mtr_t* mtr); /*!< in: mini-transaction */
/**********************************************************************//** /** Parse and optionally apply MLOG_ZIP_PAGE_COMPRESS.
Parses a log record of compressing an index page. @param[in] ptr log record
@return end of log record or NULL */ @param[in] end_ptr end of log
byte* @param[in,out] block ROW_FORMAT=COMPRESSED block, or NULL for parsing only
page_zip_parse_compress( @return end of log record
/*====================*/ @retval NULL if the log record is incomplete */
byte* ptr, /*!< in: buffer */ byte* page_zip_parse_compress(const byte* ptr, const byte* end_ptr,
byte* end_ptr, /*!< in: buffer end */ buf_block_t* block);
page_t* page, /*!< out: uncompressed page */
page_zip_des_t* page_zip); /*!< out: compressed page */
#endif /* !UNIV_INNOCHECKSUM */ #endif /* !UNIV_INNOCHECKSUM */
......
...@@ -1690,7 +1690,7 @@ recv_parse_or_apply_log_rec_body( ...@@ -1690,7 +1690,7 @@ recv_parse_or_apply_log_rec_body(
break; break;
case MLOG_ZIP_PAGE_COMPRESS: case MLOG_ZIP_PAGE_COMPRESS:
/* Allow anything in page_type when creating a page. */ /* 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; break;
case MLOG_ZIP_PAGE_COMPRESS_NO_DATA: case MLOG_ZIP_PAGE_COMPRESS_NO_DATA:
if (NULL != (ptr = mlog_parse_index( if (NULL != (ptr = mlog_parse_index(
......
...@@ -4846,23 +4846,20 @@ page_zip_copy_recs( ...@@ -4846,23 +4846,20 @@ page_zip_copy_recs(
page_zip_compress_write_log(page_zip, page, index, mtr); page_zip_compress_write_log(page_zip, page, index, mtr);
} }
/**********************************************************************//** /** Parse and optionally apply MLOG_ZIP_PAGE_COMPRESS.
Parses a log record of compressing an index page. @param[in] ptr log record
@return end of log record or NULL */ @param[in] end_ptr end of log
byte* @param[in,out] block ROW_FORMAT=COMPRESSED block, or NULL for parsing only
page_zip_parse_compress( @return end of log record
/*====================*/ @retval NULL if the log record is incomplete */
byte* ptr, /*!< in: buffer */ byte* page_zip_parse_compress(const byte* ptr, const byte* end_ptr,
byte* end_ptr,/*!< in: buffer end */ buf_block_t* block)
page_t* page, /*!< out: uncompressed page */
page_zip_des_t* page_zip)/*!< out: compressed page */
{ {
ulint size; ulint size;
ulint trailer_size; ulint trailer_size;
ut_ad(ptr != NULL); ut_ad(ptr != NULL);
ut_ad(end_ptr!= NULL); ut_ad(end_ptr!= NULL);
ut_ad(!page == !page_zip);
if (UNIV_UNLIKELY(ptr + (2 + 2) > end_ptr)) { if (UNIV_UNLIKELY(ptr + (2 + 2) > end_ptr)) {
...@@ -4879,14 +4876,22 @@ page_zip_parse_compress( ...@@ -4879,14 +4876,22 @@ page_zip_parse_compress(
return(NULL); return(NULL);
} }
if (page) { if (block) {
if (!page_zip || page_zip_get_size(page_zip) < size) { 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: corrupt:
recv_sys->found_corrupt_log = TRUE; recv_sys->found_corrupt_log = TRUE;
return(NULL); 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_PREV, ptr, 4);
memcpy(page_zip->data + FIL_PAGE_NEXT, ptr + 4, 4); memcpy(page_zip->data + FIL_PAGE_NEXT, ptr + 4, 4);
memcpy(page_zip->data + FIL_PAGE_TYPE, ptr + 8, size); memcpy(page_zip->data + FIL_PAGE_TYPE, ptr + 8, size);
...@@ -4896,14 +4901,14 @@ page_zip_parse_compress( ...@@ -4896,14 +4901,14 @@ page_zip_parse_compress(
memcpy(page_zip->data + page_zip_get_size(page_zip) memcpy(page_zip->data + page_zip_get_size(page_zip)
- trailer_size, ptr + 8 + size, trailer_size); - 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))) { TRUE))) {
goto corrupt; goto corrupt;
} }
} }
return(ptr + 8 + size + trailer_size); return(const_cast<byte*>(ptr) + 8 + size + trailer_size);
} }
#endif /* !UNIV_INNOCHECKSUM */ #endif /* !UNIV_INNOCHECKSUM */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment