Skip to content
  • Libing Song's avatar
    c8d3b386
    BUG#26666609 SLAVE HANGS - WAITING FOR TABLE METADATA LOCK · c8d3b386
    Libing Song authored
    ANALYSIS
    ========
    REPAIR/OPTIMIZE/ANALYZE TABLE and
    ALTER TABLE ... REPAIR/OPTIMIZE/ANALYZE PARTITION
    statements maintain the tables one bye one. The metadata lock
    of the table is released immediately after it is maintained. That is
    earlier than the statement is binlogged and committed. That means
    the following statements which updates the same table may be binlogged
    earlier than it. Or they go into the same binlog flush queue. That
    meant they could be applied on slave parallel. It would cause a
    deadlock if --slave-preserve-commit-order is ON.
    
    For example:
    REPAIR TABLE t1;
    INSERT INTO t1 VALUES(1);
    go into to the same flush queue. They were binlogged with below information.
    
    REPAIR TABLE t1;
    INSERT INTO t1 VALUES(1);
    
    FIX
    ===
    m_last_blocking_transaction is added to store the sequence_number of the
    transactions which may not safe to parallel with the following transaction.
    The last_committed of the following transactions will be reset to
    m_last_blocking_transaction if their original last_committed is smaller
    than m_last_blocking_transaction.
    c8d3b386
    BUG#26666609 SLAVE HANGS - WAITING FOR TABLE METADATA LOCK
    Libing Song authored
    ANALYSIS
    ========
    REPAIR/OPTIMIZE/ANALYZE TABLE and
    ALTER TABLE ... REPAIR/OPTIMIZE/ANALYZE PARTITION
    statements maintain the tables one bye one. The metadata lock
    of the table is released immediately after it is maintained. That is
    earlier than the statement is binlogged and committed. That means
    the following statements which updates the same table may be binlogged
    earlier than it. Or they go into the same binlog flush queue. That
    meant they could be applied on slave parallel. It would cause a
    deadlock if --slave-preserve-commit-order is ON.
    
    For example:
    REPAIR TABLE t1;
    INSERT INTO t1 VALUES(1);
    go into to the same flush queue. They were binlogged with below information.
    
    REPAIR TABLE t1;
    INSERT INTO t1 VALUES(1);
    
    FIX
    ===
    m_last_blocking_transaction is added to store the sequence_number of the
    transactions which may not safe to parallel with the following transaction.
    The last_committed of the following transactions will be reset to
    m_last_blocking_transaction if their original last_committed is smaller
    than m_last_blocking_transaction.
Loading