• Brandon Nesterenko's avatar
    MDEV-13915: STOP SLAVE takes very long time on a busy system · 0a99d457
    Brandon Nesterenko authored
    The problem is that a parallel replica would not immediately stop
    running/queued transactions when issued STOP SLAVE. That is, it
    allowed the current group of transactions to run, and sometimes the
    transactions which belong to the next group could be started and run
    through commit after STOP SLAVE was issued too, if the last group
    had started committing. This would lead to long periods to wait for
    all waiting transactions to finish.
    
    This patch updates a parallel replica to try and abort immediately
    and roll-back any ongoing transactions. The exception to this is any
    transactions which are non-transactional (e.g. those modifying
    sequences or non-transactional tables), and any prior transactions,
    will be run to completion.
    
    The specifics are as follows:
    
     1. A new stage was added to SHOW PROCESSLIST output for the SQL
    Thread when it is waiting for a replica thread to either rollback or
    finish its transaction before stopping. This stage presents as
    “Waiting for worker thread to stop”
    
     2. Worker threads which error or are killed no longer perform GCO
    cleanup if there is a concurrently running prior transaction. This
    is because a worker thread scheduled to run in a future GCO could be
    killed and incorrectly perform cleanup of the active GCO.
    
     3. Refined cases when the FL_TRANSACTIONAL flag is added to GTID
    binlog events to disallow adding it to transactions which modify
    both transactional and non-transactional engines when the binlogging
    configuration allow the modifications to exist in the same event,
    i.e. when using binlog_direct_non_trans_update == 0 and
    binlog_format == statement.
    
     4. A few existing MTR tests relied on the completion of certain
    transactions after issuing STOP SLAVE, and were re-recorded
    (potentially with added synchronizations) under the new rollback
    behavior.
    
    Reviewed By
    ===========
    Andrei Elkin <andrei.elkin@mariadb.com>
    0a99d457
mysqld.cc 334 KB