• Marko Mäkelä's avatar
    MDEV-17958 Make bug-endian innodb_checksum_algorithm=crc32 optional · 1a780eef
    Marko Mäkelä authored
    In MySQL 5.7, it was noticed that files are not portable between
    big-endian and little-endian processor architectures
    (such as SPARC and x86), because the original implementation of
    innodb_checksum_algorithm=crc32 was not byte order agnostic.
    
    A byte order agnostic implementation of innodb_checksum_algorithm=crc32
    was only added to MySQL 5.7, not backported to 5.6. Consequently,
    MariaDB Server versions 10.0 and 10.1 only contain the CRC-32C
    implementation that works incorrectly on big-endian architectures,
    and MariaDB Server 10.2.2 got the byte-order agnostic CRC-32C
    implementation from MySQL 5.7.
    
    MySQL 5.7 introduced a "legacy crc32" variant that is functionally
    equivalent to the big-endian version of the original crc32 implementation.
    Thanks to this variant, old data files can be transferred from big-endian
    systems to newer versions.
    
    Introducing new variants of checksum algorithms (without introducing
    new names for them, or something on the pages themselves to identify
    the algorithm) generally is a bad idea, because each checksum algorithm
    is like a lottery ticket. The more algorithms you try, the more likely
    it will be for the checksum to match on a corrupted page.
    
    So, essentially MySQL 5.7 weakened innodb_checksum_algorithm=crc32,
    and MariaDB 10.2.2 inherited this weakening.
    
    We introduce a build option that together with MDEV-17957
    makes innodb_checksum_algorithm=strict_crc32 strict again
    by only allowing one variant of the checksum to match.
    
    WITH_INNODB_BUG_ENDIAN_CRC32: A new cmake option for enabling the
    bug-compatible "legacy crc32" checksum. This is only enabled on
    big-endian systems by default, to facilitate an upgrade from
    MariaDB 10.0 or 10.1. Checked by #ifdef INNODB_BUG_ENDIAN_CRC32.
    
    ut_crc32_byte_by_byte: Remove (unused function).
    
    legacy_big_endian_checksum: Remove. This variable seems to have
    unnecessarily complicated the logic. When the weakening is enabled,
    we must always fall back to the buggy checksum.
    
    buf_page_check_crc32(): A helper function to compute one or
    two CRC-32C variants.
    1a780eef
page0zip.cc 145 KB