• Marko Mäkelä's avatar
    MDEV-26110: Do not rely on alignment on static allocation · 82d59945
    Marko Mäkelä authored
    It is implementation-defined whether alignment requirements
    that are larger than std::max_align_t (typically 8 or 16 bytes)
    will be honored by the compiler and linker.
    
    It turns out that on IBM AIX, both alignas() and MY_ALIGNED()
    only guarantees alignment up to 16 bytes.
    
    For some data structures, specifying alignment to the CPU
    cache line size (typically 64 or 128 bytes) is a mere performance
    optimization, and we do not really care whether the requested
    alignment is guaranteed.
    
    But, for the correct operation of direct I/O, we do require that
    the buffers be aligned at a block size boundary.
    
    field_ref_zero: Define as a pointer, not an array.
    For innochecksum, we can make this point to unaligned memory;
    for anything else, we will allocate an aligned buffer from the heap.
    This buffer will be used for overwriting freed data pages when
    innodb_immediate_scrub_data_uncompressed=ON. And exactly that code
    hit an assertion failure on AIX, in the test innodb.innodb_scrub.
    
    log_sys.checkpoint_buf: Define as a pointer to aligned memory
    that is allocated from heap.
    
    log_t::file::write_header_durable(): Reuse log_sys.checkpoint_buf
    instead of trying to allocate an aligned buffer from the stack.
    82d59945
log0log.h 26.4 KB