• Luis Soares's avatar
    Bug#13693012: SLAVE CRASHING ON INSERT STATEMENT WITH MERGE TABLE · 580664b2
    Luis Soares authored
    PROBLEM: After WL 4144, when using MyISAM Merge tables, the routine
    open_and_lock_tables will append to the list of tables to lock, the
    base tables that make up the MERGE table. This has two side-effects in
    replication: 
    
      1. On the master side, we log additional table maps for the base
         tables, since they appear in the list of locked tables, even
         though we don't really use them at the slave.
    
      2. On the slave side, when opening a MERGE table while applying a
         ROW event, additional tables are appended to the list of tables
         to lock.
    
    Side-effect #1 is not harmful. It's just that when using MyISAM Merge
    tables a few table maps more may be logged.
    
    Side-effect #2, is harmful, because the list rli->tables_to_lock is an
    extended structure from TABLE_LIST in which the extra fields are
    filled from the table maps that are processed. Since
    open_and_lock_tables appends tables to the list after all table map
    events have been processed we end up with entries without
    replication/table map data on them. Thus when trying to access that
    info for these extra tables, the server will crash.
    
    SOLUTION: We fix side-effect #2 by making sure that we access the
    replication part of the structure for those in the list that were
    accounted for when processing the correspondent table map events. All
    in all, we never go beyond rli->tables_to_lock_count.
    
    We also deploy an assertion when clearing rli->tables_to_lock, making
    sure that the base tables are not in the list anymore (were closed in
    close_thread_tables).
    580664b2
log_event.cc 322 KB