• Venkatesh Duggirala's avatar
    BUG#16290902 DROP TEMP TABLE IF EXISTS CAN CAUSE POINT · bf2c49d3
    Venkatesh Duggirala authored
    IN TIME RECOVERY FAILURE ON SLAVES
    
    Problem:
    DROP TEMP TABLE IF EXISTS commands can cause point
    in time recovery (re-applying binlog) failures.
    
    Analyses:
    In RBR, 'DROP TEMPORARY TABLE' commands are
    always binlogged by adding 'IF EXISTS' clauses.
    Also, the slave SQL thread will not check replicate.* filter
    rules for "DROP TEMPORARY TABLE IF EXISTS" queries.
    If log-slave-updates is enabled on slave, these queries
    will be binlogged in the format of "USE `db`;
    DROP TEMPORARY TABLE IF EXISTS `t1`;" irrespective
    of filtering rules and irrespective of the `db` existence.
    When users try to recover slave from it's own binlog,
    use `db` command might fail if `db` is not present on slave.
    
    Fix:
    At the time of writing the 'DROP TEMPORARY TABLE
    IF EXISTS' query into the binlog, 'use `db`' will not be
    present and the table name in the query will be a fully
    qualified table name.
    Eg:
    'USE `db`; DROP TEMPORARY TABLE IF EXISTS `t1`;'
    will be logged as
    'DROP TEMPORARY TABLE IF EXISTS `db`.`t1`;'.
    bf2c49d3
binlog_database.result 7.9 KB