Commit 54765aaa authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-15524 Do not disable page checksums for temporary tables

buf_flush_init_for_writing(): Remove the parameter skip_checksum.
parent 4fa18d52
......@@ -4044,7 +4044,7 @@ xb_space_create_file(
const page_size_t page_size(flags);
if (!page_size.is_compressed()) {
buf_flush_init_for_writing(NULL, page, NULL, 0, false);
buf_flush_init_for_writing(NULL, page, NULL, 0);
ret = os_file_write(IORequestWrite, path, *file, page, 0,
UNIV_PAGE_SIZE);
......@@ -4061,7 +4061,7 @@ xb_space_create_file(
page_zip.m_end = page_zip.m_nonempty =
page_zip.n_blobs = 0;
buf_flush_init_for_writing(NULL, page, &page_zip, 0, false);
buf_flush_init_for_writing(NULL, page, &page_zip, 0);
ret = os_file_write(IORequestWrite, path, *file,
page_zip.data, 0, zip_size);
......
......@@ -832,18 +832,14 @@ buf_flush_update_zip_checksum(
@param[in] block buffer block; NULL if bypassing the buffer pool
@param[in,out] page page frame
@param[in,out] page_zip_ compressed page, or NULL if uncompressed
@param[in] newest_lsn newest modification LSN to the page
@param[in] skip_checksum whether to disable the page checksum */
@param[in] newest_lsn newest modification LSN to the page */
void
buf_flush_init_for_writing(
const buf_block_t* block,
byte* page,
void* page_zip_,
lsn_t newest_lsn,
bool skip_checksum)
lsn_t newest_lsn)
{
ib_uint32_t checksum = BUF_NO_CHECKSUM_MAGIC;
ut_ad(block == NULL || block->frame == page);
ut_ad(block == NULL || page_zip_ == NULL
|| &block->page.zip == page_zip_);
......@@ -895,111 +891,97 @@ buf_flush_init_for_writing(
mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
newest_lsn);
if (skip_checksum) {
ut_ad(block == NULL
|| block->page.id.space() == SRV_TMP_SPACE_ID);
ut_ad(page_get_space_id(page) == SRV_TMP_SPACE_ID);
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum);
} else {
if (block != NULL && UNIV_PAGE_SIZE == 16384) {
/* The page type could be garbage in old files
created before MySQL 5.5. Such files always
had a page size of 16 kilobytes. */
ulint page_type = fil_page_get_type(page);
ulint reset_type = page_type;
switch (block->page.id.page_no() % 16384) {
case 0:
reset_type = block->page.id.page_no() == 0
? FIL_PAGE_TYPE_FSP_HDR
: FIL_PAGE_TYPE_XDES;
if (block && srv_page_size == 16384) {
/* The page type could be garbage in old files
created before MySQL 5.5. Such files always
had a page size of 16 kilobytes. */
ulint page_type = fil_page_get_type(page);
ulint reset_type = page_type;
switch (block->page.id.page_no() % 16384) {
case 0:
reset_type = block->page.id.page_no() == 0
? FIL_PAGE_TYPE_FSP_HDR
: FIL_PAGE_TYPE_XDES;
break;
case 1:
reset_type = FIL_PAGE_IBUF_BITMAP;
break;
case FSP_TRX_SYS_PAGE_NO:
if (block->page.id.page_no()
== TRX_SYS_PAGE_NO
&& block->page.id.space()
== TRX_SYS_SPACE) {
reset_type = FIL_PAGE_TYPE_TRX_SYS;
break;
case 1:
reset_type = FIL_PAGE_IBUF_BITMAP;
}
/* fall through */
default:
switch (page_type) {
case FIL_PAGE_INDEX:
case FIL_PAGE_RTREE:
case FIL_PAGE_UNDO_LOG:
case FIL_PAGE_INODE:
case FIL_PAGE_IBUF_FREE_LIST:
case FIL_PAGE_TYPE_ALLOCATED:
case FIL_PAGE_TYPE_SYS:
case FIL_PAGE_TYPE_TRX_SYS:
case FIL_PAGE_TYPE_BLOB:
case FIL_PAGE_TYPE_ZBLOB:
case FIL_PAGE_TYPE_ZBLOB2:
break;
case FSP_TRX_SYS_PAGE_NO:
if (block->page.id.page_no()
== TRX_SYS_PAGE_NO
&& block->page.id.space()
== TRX_SYS_SPACE) {
reset_type = FIL_PAGE_TYPE_TRX_SYS;
break;
}
/* fall through */
case FIL_PAGE_TYPE_FSP_HDR:
case FIL_PAGE_TYPE_XDES:
case FIL_PAGE_IBUF_BITMAP:
/* These pages should have
predetermined page numbers
(see above). */
default:
switch (page_type) {
case FIL_PAGE_INDEX:
case FIL_PAGE_RTREE:
case FIL_PAGE_UNDO_LOG:
case FIL_PAGE_INODE:
case FIL_PAGE_IBUF_FREE_LIST:
case FIL_PAGE_TYPE_ALLOCATED:
case FIL_PAGE_TYPE_SYS:
case FIL_PAGE_TYPE_TRX_SYS:
case FIL_PAGE_TYPE_BLOB:
case FIL_PAGE_TYPE_ZBLOB:
case FIL_PAGE_TYPE_ZBLOB2:
break;
case FIL_PAGE_TYPE_FSP_HDR:
case FIL_PAGE_TYPE_XDES:
case FIL_PAGE_IBUF_BITMAP:
/* These pages should have
predetermined page numbers
(see above). */
default:
reset_type = FIL_PAGE_TYPE_UNKNOWN;
break;
}
}
if (UNIV_UNLIKELY(page_type != reset_type)) {
ib::info()
<< "Resetting invalid page "
<< block->page.id << " type "
<< page_type << " to "
<< reset_type << " when flushing.";
fil_page_set_type(page, reset_type);
reset_type = FIL_PAGE_TYPE_UNKNOWN;
break;
}
}
switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) {
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
checksum = buf_calc_page_crc32(page);
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
checksum);
break;
case SRV_CHECKSUM_ALGORITHM_INNODB:
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
checksum = (ib_uint32_t) buf_calc_page_new_checksum(
page);
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
checksum);
checksum = (ib_uint32_t) buf_calc_page_old_checksum(
page);
break;
case SRV_CHECKSUM_ALGORITHM_NONE:
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
checksum);
break;
/* no default so the compiler will emit a warning if
new enum is added and not handled here */
if (UNIV_UNLIKELY(page_type != reset_type)) {
ib::info()
<< "Resetting invalid page "
<< block->page.id << " type "
<< page_type << " to "
<< reset_type << " when flushing.";
fil_page_set_type(page, reset_type);
}
}
/* With the InnoDB checksum, we overwrite the first 4 bytes of
the end lsn field to store the old formula checksum. Since it
depends also on the field FIL_PAGE_SPACE_OR_CHKSUM, it has to
be calculated after storing the new formula checksum.
uint32_t checksum;
In other cases we write the same value to both fields.
If CRC32 is used then it is faster to use that checksum
(calculated above) instead of calculating another one.
We can afford to store something other than
buf_calc_page_old_checksum() or BUF_NO_CHECKSUM_MAGIC in
this field because the file will not be readable by old
versions of MySQL/InnoDB anyway (older than MySQL 5.6.3) */
switch (srv_checksum_algorithm_t(srv_checksum_algorithm)) {
case SRV_CHECKSUM_ALGORITHM_INNODB:
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
checksum = buf_calc_page_new_checksum(page);
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
checksum);
/* With the InnoDB checksum, we overwrite the first 4 bytes of
the end lsn field to store the old formula checksum. Since it
depends also on the field FIL_PAGE_SPACE_OR_CHKSUM, it has to
be calculated after storing the new formula checksum. */
checksum = buf_calc_page_old_checksum(page);
break;
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
/* In other cases we write the same checksum to both fields. */
checksum = buf_calc_page_crc32(page);
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
checksum);
break;
case SRV_CHECKSUM_ALGORITHM_NONE:
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
checksum = BUF_NO_CHECKSUM_MAGIC;
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
checksum);
break;
/* no default so the compiler will emit a warning if
new enum is added and not handled here */
}
mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
checksum);
......@@ -1025,8 +1007,8 @@ buf_flush_write_block_low(
ut_ad(space->purpose == FIL_TYPE_TEMPORARY
|| space->purpose == FIL_TYPE_IMPORT
|| space->purpose == FIL_TYPE_TABLESPACE);
const bool is_temp = space->purpose == FIL_TYPE_TEMPORARY;
ut_ad(is_temp == fsp_is_system_temporary(space->id));
ut_ad((space->purpose == FIL_TYPE_TEMPORARY)
== fsp_is_system_temporary(space->id));
page_t* frame = NULL;
#ifdef UNIV_DEBUG
buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
......@@ -1088,7 +1070,7 @@ buf_flush_write_block_low(
reinterpret_cast<const buf_block_t*>(bpage),
reinterpret_cast<const buf_block_t*>(bpage)->frame,
bpage->zip.data ? &bpage->zip : NULL,
bpage->newest_modification, is_temp);
bpage->newest_modification);
break;
}
......@@ -1098,7 +1080,8 @@ buf_flush_write_block_low(
Given the nature and load of temporary tablespace doublewrite buffer
adds an overhead during flushing. */
if (is_temp || space->atomic_write_supported
if (space->purpose == FIL_TYPE_TEMPORARY
|| space->atomic_write_supported
|| !srv_use_doublewrite_buf
|| buf_dblwr == NULL) {
......@@ -1126,7 +1109,7 @@ buf_flush_write_block_low(
are working on. */
if (sync) {
ut_ad(flush_type == BUF_FLUSH_SINGLE_PAGE);
if (!is_temp) {
if (space->purpose != FIL_TYPE_TEMPORARY) {
fil_flush(space);
}
......
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2017, MariaDB Corporation.
Copyright (c) 2014, 2018, 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
......@@ -80,15 +80,13 @@ buf_flush_write_complete(
@param[in] block buffer block; NULL if bypassing the buffer pool
@param[in,out] page page frame
@param[in,out] page_zip_ compressed page, or NULL if uncompressed
@param[in] newest_lsn newest modification LSN to the page
@param[in] skip_checksum whether to disable the page checksum */
@param[in] newest_lsn newest modification LSN to the page */
void
buf_flush_init_for_writing(
const buf_block_t* block,
byte* page,
void* page_zip_,
lsn_t newest_lsn,
bool skip_checksum = false);
lsn_t newest_lsn);
# if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
/********************************************************************//**
......
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