MDEV-15527 fixup for innodb_checksum_algorithm=full_crc32

This commit is contained in:
Marko Mäkelä 2021-03-31 10:55:21 +03:00
parent 50de71b026
commit 8341f582b2
3 changed files with 38 additions and 17 deletions

View file

@ -0,0 +1,5 @@
[strict_crc32]
--innodb-checksum-algorithm=strict_crc32
[strict_full_crc32]
--innodb-checksum-algorithm=strict_full_crc32

View file

@ -0,0 +1,5 @@
[strict_crc32]
--innodb-checksum-algorithm=strict_crc32
[strict_full_crc32]
--innodb-checksum-algorithm=strict_full_crc32

View file

@ -3355,26 +3355,30 @@ struct fil_iterator_t {
/** InnoDB writes page by page when there is page compressed /** InnoDB writes page by page when there is page compressed
tablespace involved. It does help to save the disk space when tablespace involved. It does help to save the disk space when
punch hole is enabled punch hole is enabled
@param iter Tablespace iterator @param iter Tablespace iterator
@param full_crc32 whether the file is in the full_crc32 format
@param write_request Request to write into the file @param write_request Request to write into the file
@param offset offset of the file to be written @param offset offset of the file to be written
@param writeptr buffer to be written @param writeptr buffer to be written
@param n_bytes number of bytes to be written @param n_bytes number of bytes to be written
@param try_punch_only Try the range punch only because the @param try_punch_only Try the range punch only because the
current range is full of empty pages current range is full of empty pages
@return DB_SUCCESS */ @return DB_SUCCESS */
static static
dberr_t fil_import_compress_fwrite(const fil_iterator_t &iter, dberr_t fil_import_compress_fwrite(const fil_iterator_t &iter,
bool full_crc32,
const IORequest &write_request, const IORequest &write_request,
os_offset_t offset, os_offset_t offset,
const byte *writeptr, const byte *writeptr,
ulint n_bytes, ulint n_bytes,
bool try_punch_only= false) bool try_punch_only= false)
{ {
dberr_t err= os_file_punch_hole(iter.file, offset, n_bytes); if (dberr_t err= os_file_punch_hole(iter.file, offset, n_bytes))
if (err != DB_SUCCESS || try_punch_only)
return err; return err;
if (try_punch_only)
return DB_SUCCESS;
for (ulint j= 0; j < n_bytes; j+= srv_page_size) for (ulint j= 0; j < n_bytes; j+= srv_page_size)
{ {
/* Read the original data length from block and /* Read the original data length from block and
@ -3384,20 +3388,27 @@ dberr_t fil_import_compress_fwrite(const fil_iterator_t &iter,
if (j || offset) if (j || offset)
{ {
n_write_bytes= mach_read_from_2(writeptr + j + FIL_PAGE_DATA); n_write_bytes= mach_read_from_2(writeptr + j + FIL_PAGE_DATA);
const unsigned ptype= mach_read_from_2(writeptr + j + FIL_PAGE_TYPE); const unsigned ptype= mach_read_from_2(writeptr + j + FIL_PAGE_TYPE);
/* Ignore the empty page */ /* Ignore the empty page */
if (ptype == 0 && n_write_bytes == 0) if (ptype == 0 && n_write_bytes == 0)
continue; continue;
n_write_bytes+= FIL_PAGE_DATA + FIL_PAGE_ENCRYPT_COMP_METADATA_LEN; if (full_crc32)
n_write_bytes= buf_page_full_crc32_size(writeptr + j,
nullptr, nullptr);
else
{
n_write_bytes+= ptype == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED
? FIL_PAGE_DATA + FIL_PAGE_ENCRYPT_COMP_METADATA_LEN
: FIL_PAGE_DATA + FIL_PAGE_COMP_METADATA_LEN;
}
} }
err= os_file_write(write_request, iter.filepath, iter.file, if (dberr_t err= os_file_write(write_request, iter.filepath, iter.file,
writeptr + j, offset + j, n_write_bytes); writeptr + j, offset + j, n_write_bytes))
if (err != DB_SUCCESS) return err;
break;
} }
return err; return DB_SUCCESS;
} }
/********************************************************************//** /********************************************************************//**
@ -3721,8 +3732,8 @@ not_encrypted:
if (page_compressed && punch_hole) { if (page_compressed && punch_hole) {
err = fil_import_compress_fwrite( err = fil_import_compress_fwrite(
iter, write_request, offset, writeptr, n_bytes, iter, full_crc32, write_request, offset,
!updated); writeptr, n_bytes, !updated);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
punch_hole = false; punch_hole = false;