• Kristian Nielsen's avatar
    MDEV-7249: Performance problem in parallel replication with multi-level slaves · 184f718f
    Kristian Nielsen authored
    Parallel replication (in 10.0 / "conservative" mode) relies on binlog group
    commits to group transactions that can be safely run in parallel on the
    slave. The --binlog-commit-wait-count and --binlog-commit-wait-usec options
    exist to increase the number of commits per group. But in case of conflicts
    between transactions, this can cause unnecessary delay and reduced througput,
    especially on a slave where commit order is fixed.
    
    This patch adds a heuristics to reduce this problem. When transaction T1 goes
    to commit, it will first wait for N transactions to queue up for a group
    commit. However, if we detect that another transaction T2 is waiting for a row
    lock held by T1, then we will skip the wait and let T1 commit immediately,
    releasing locks and let T2 continue.
    
    On a slave, this avoids the unfortunate situation where T1 is waiting for T2
    to join the group commit, but T2 is waiting for T1 to release locks, causing
    no work to be done for the duration of the --binlog-commit-wait-usec timeout.
    
    (The heuristic seems reasonable on the master as well, so it is enabled for
    all transactions, not just replication transactions).
    184f718f
transaction.cc 24.9 KB