• Sven Sandberg's avatar
    BUG#12574820: binlog.binlog_tmp_table timing out in daily and weekly trunk run · de377681
    Sven Sandberg authored
    Problem: MYSQL_BIN_LOG::reset_logs acquires mutexes in wrong order.
    The correct order is first LOCK_thread_count and then LOCK_log. This function
    does it the other way around. This leads to deadlock when run in parallel
    with a thread that takes the two locks in correct order. For example, a thread
    that disconnects will take the locks in the correct order.
    Fix: change order of the locks in MYSQL_BIN_LOG::reset_logs:
    first LOCK_thread_count and then LOCK_log.
    
    
    mysql-test/suite/binlog/r/binlog_reset_master.result:
      added result file
    mysql-test/suite/binlog/t/binlog_reset_master.test:
      Added test case that demonstrates deadlock because of wrong mutex order.
      The deadlock is between two threads:
       - RESET MASTER acquires mutexes in wrong order.
       - client thread shutdown code acquires mutexes in right order.
      Actually, this test case does not produce deadlock in 5.1, probably
      the client thread shutdown code does not hold both mutexes at the same
      time. However, the bug existed in 5.1 (mutexes are taken in the wrong
      order) so we push the test case to 5.1 too, to prevent future
      regressions.
    sql/log.cc:
      Change mutex acquisition to the correct order:
      first LOCK_thread_count, then LOCK_log.
    sql/mysqld.cc:
      Add debug code to synchronize test case.
    de377681
binlog_reset_master.result 14 Bytes