diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-03-18 14:08:43 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-03-18 14:08:43 +0200 |
commit | 6b6fa3cdb16ae7b4bc9e307c7d9b9012a055548c (patch) | |
tree | 6e13e7d7002b7ce383befbc7bad2131dd890ec9a /extra/innochecksum.cc | |
parent | 2151aed44d15d7055d7608af94b9a01093ec77c0 (diff) | |
download | mariadb-git-6b6fa3cdb16ae7b4bc9e307c7d9b9012a055548c.tar.gz |
MDEV-18644: Support full_crc32 for page_compressed
This is a follow-up task to MDEV-12026, which introduced
innodb_checksum_algorithm=full_crc32 and a simpler page format.
MDEV-12026 did not enable full_crc32 for page_compressed tables,
which we will be doing now.
This is joint work with Thirunarayanan Balathandayuthapani.
For innodb_checksum_algorithm=full_crc32 we change the
page_compressed format as follows:
FIL_PAGE_TYPE: The most significant bit will be set to indicate
page_compressed format. The least significant bits will contain
the compressed page size, rounded up to a multiple of 256 bytes.
The checksum will be stored in the last 4 bytes of the page
(whether it is the full page or a page_compressed page whose
size is determined by FIL_PAGE_TYPE), covering all preceding
bytes of the page. If encryption is used, then the page will
be encrypted between compression and computing the checksum.
For page_compressed, FIL_PAGE_LSN will not be repeated at
the end of the page.
FSP_SPACE_FLAGS (already implemented as part of MDEV-12026):
We will store the innodb_compression_algorithm that may be used
to compress pages. Previously, the choice of algorithm was written
to each compressed data page separately, and one would be unable
to know in advance which compression algorithm(s) are used.
fil_space_t::full_crc32_page_compressed_len(): Determine if the
page_compressed algorithm of the tablespace needs to know the
exact length of the compressed data. If yes, we will reserve and
write an extra byte for this right before the checksum.
buf_page_is_compressed(): Determine if a page uses page_compressed
(in any innodb_checksum_algorithm).
fil_page_decompress(): Pass also fil_space_t::flags so that the
format can be determined.
buf_page_is_zeroes(): Check if a page is full of zero bytes.
buf_page_full_crc32_is_corrupted(): Renamed from
buf_encrypted_full_crc32_page_is_corrupted(). For full_crc32,
we always simply validate the checksum to the page contents,
while the physical page size is explicitly specified by an
unencrypted part of the page header.
buf_page_full_crc32_size(): Determine the size of a full_crc32 page.
buf_dblwr_check_page_lsn(): Make this a debug-only function, because
it involves potentially costly lookups of fil_space_t.
create_table_info_t::check_table_options(),
ha_innobase::check_if_supported_inplace_alter(): Do allow the creation
of SPATIAL INDEX with full_crc32 also when page_compressed is used.
commit_cache_norebuild(): Preserve the compression algorithm when
updating the page_compression_level.
dict_tf_to_fsp_flags(): Set the flags for page compression algorithm.
FIXME: Maybe there should be a table option page_compression_algorithm
and a session variable to back it?
Diffstat (limited to 'extra/innochecksum.cc')
-rw-r--r-- | extra/innochecksum.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc index 55d41fc04ad..dc49e3e0817 100644 --- a/extra/innochecksum.cc +++ b/extra/innochecksum.cc @@ -281,7 +281,7 @@ static void init_page_size(const byte* buf) const unsigned flags = mach_read_from_4(buf + FIL_PAGE_DATA + FSP_SPACE_FLAGS); - if (FSP_FLAGS_FCRC32_HAS_MARKER(flags)) { + if (fil_space_t::full_crc32(flags)) { srv_page_size = fil_space_t::logical_size(flags); physical_page_size = srv_page_size; return; @@ -461,7 +461,7 @@ is_page_corrupted( return (false); } - if (!zip_size) { + if (!zip_size && (!is_compressed || !use_full_crc32)) { /* check the stored log sequence numbers for uncompressed tablespace. */ logseq = mach_read_from_4(buf + FIL_PAGE_LSN + 4); @@ -613,8 +613,10 @@ static bool update_checksum(byte* page, ulint flags) } } else if (use_full_crc32) { - checksum = buf_calc_page_full_crc32(page); - byte* c = page + physical_page_size - FIL_PAGE_FCRC32_CHECKSUM; + ulint payload = buf_page_full_crc32_size(page, NULL, NULL) + - FIL_PAGE_FCRC32_CHECKSUM; + checksum = ut_crc32(page, payload); + byte* c = page + payload; if (mach_read_from_4(c) == checksum) return false; mach_write_to_4(c, checksum); if (is_log_enabled) { |