• Sujatha Sivakumar's avatar
    Bug#17942050:KILL OF TRUNCATE TABLE WILL LEAD TO BINARY LOG · 58b98078
    Sujatha Sivakumar authored
    WRITTEN WHILE ROWS REMAINS
    
    Problem:
    ========
    When truncate table fails while using transactional based
    engines even though the operation errors out we still
    continue and log it to binlog. Because of this master has
    data but the truncate will be written to binary log which
    will cause inconsistency.
    
    Analysis:
    ========
    Truncate table can happen either through drop and create of
    table or by deleting rows. In the second case the existing
    code is written in such a way that even if an error occurs
    the truncate statement will always be binlogged. Which is not
    correct.
    
    Binlogging of TRUNCATE TABLE statement should check whether
    truncate is executed "transactionally or not". If the table
    is transaction based we log the TRUNCATE TABLE only on
    successful completion.
    
    If table is non transactional there are possibilities that on
    error we could have partial changes done hence in such cases
    we do log in spite of errors as some of the lines might have
    been removed, so the statement has to be sent to slave.
    
    Fix:
    ===
    Using table handler whether truncate table is being executed
    in transaction based mode or not is identified and statement
    is binlogged accordingly.
    58b98078
binlog_truncate_kill.test 1.96 KB