• petr/cps@mysql.com/owlet.local's avatar
    Fix for Bug #17544 "Cannot do atomic log rotate", · 6846f8d9
    petr/cps@mysql.com/owlet.local authored
    Bug #21785 "Server crashes after rename of the log table" and
    Bug #21966 "Strange warnings on create like/repair of the log
                tables"
    
    According to the patch, from now on, one should use RENAME to
    perform a log table rotation (this should also be reflected in
    the manual).
    
    Here is a sample:
    
    use mysql;
    CREATE TABLE IF NOT EXISTS general_log2 LIKE general_log;
    RENAME TABLE general_log TO general_log_backup, general_log2 TO general_log;
    
    The rules for Rename of the log tables are following:
          IF   1. Log tables are enabled
          AND  2. Rename operates on the log table and nothing is being
                  renamed to the log table.
          DO   3. Throw an error message.
          ELSE 4. Perform rename.
     
    The very RENAME query will go the the old (backup) table. This is
    consistent with the behavoiur we have with binlog ROTATE LOGS
    statement.
    
    Other problems, which are solved by the patch are:
    
    1) Now REPAIR of the log table is exclusive operation (as it should be), this
       also eliminates lock-related warnings. and
    2) CREATE LIKE TABLE now usese usual read lock on the source table rather
       then name lock, which is too restrictive. This way we get rid of another
       log table-related warning, which occured because of the above fact
       (as a side-effect, name lock resulted in a warning).
    6846f8d9
sql_rename.cc 9.23 KB