• Marko Mäkelä's avatar
    MDEV-14407 Assertion failure during rollback · 609d0a91
    Marko Mäkelä authored
    Rollback attempted to dereference DB_ROLL_PTR=0, which cannot possibly
    be a valid undo log pointer. A safer canonical value would be
    roll_ptr_t(1) << ROLL_PTR_INSERT_FLAG_POS
    which is what was chosen in MDEV-12288, corresponding to reset_trx_id.
    
    No deterministic test case for the bug was found. The simplest test
    cases may be related to MDEV-11415, which suppresses undo logging for
    ALGORITHM=COPY operations. In those operations, in the spirit of
    MDEV-12288, we should actually have written reset_trx_id instead of
    using the transaction identifier of the current transaction
    (and a bogus value of DB_ROLL_PTR=0). However, thanks to MySQL Bug#28432
    which I had fixed in MySQL 5.6.8 as part of WL#6255, access to the
    rebuilt table by earlier-started transactions should actually have been
    refused with ER_TABLE_DEF_CHANGED.
    
    reset_trx_id: Move the definition to data0type.cc and the declaration
    to data0type.h.
    
    btr_cur_ins_lock_and_undo(): When undo logging is disabled, use the
    safe value that corresponds to reset_trx_id.
    
    btr_cur_optimistic_insert(): Validate the DB_TRX_ID,DB_ROLL_PTR before
    inserting into a clustered index leaf page.
    
    ins_node_t::sys_buf[]: Replaces row_id_buf and trx_id_buf and some
    heap usage.
    
    row_ins_alloc_sys_fields(): Init ins_node_t::sys_buf[] to reset_trx_id.
    
    row_ins_buf(): Only if undo logging is enabled, copy trx->id
    to node->sys_buf. Otherwise, rely on the initialization in
    row_ins_alloc_sys_fields().
    
    row_purge_reset_trx_id(): Invoke mlog_write_string() with reset_trx_id
    directly. (No functional change.)
    
    trx_undo_page_report_modify(): Assert that the DB_ROLL_PTR is not 0.
    
    trx_undo_get_undo_rec_low(): Assert that the roll_ptr is valid before
    trying to dereference it.
    
    dict_index_t::is_primary(): Check if the index is the primary key.
    
    PageConverter::adjust_cluster_record(): Fix
    MDEV-15249 Crash in MVCC read after IMPORT TABLESPACE
    by resetting the system fields to reset_trx_id instead of writing
    the current transaction ID (which will be committed at the
    end of the IMPORT TABLESPACE) and DB_ROLL_PTR=0.
    This can partially be viewed as a follow-up fix of MDEV-12288,
    because IMPORT should already then have written
    DB_TRX_ID=0 and DB_ROLL_PTR=1<<55 to prevent unnecessary
    DB_TRX_ID lookups in subsequent accesses to the table.
    609d0a91
row0ins.cc 106 KB