Skip to content
  • s.sujatha's avatar
    f42e9f8f
    Bug#19843808: DEADLOCK ON FLUSH TABLES WITH READ LOCK + SHOW · f42e9f8f
    s.sujatha authored
    SLAVE STATUS
    
    Problem:
    
    If a client thread on an slave does FLUSH TABLES WITH READ
    LOCK; then master does some updates, SHOW SLAVE STATUS in
    the same client will be blocked.
    
    Analysis:
    
    Execute FLUSH TABLES WITH READ LOCK on slave and at the same
    time execute a DML on the master. Then the DML should be
    made to stop at a state "Waiting for commit lock". This
    state means that sql thread is holding rli->data_lock and
    waiting for MDL_COMMIT lock. Now in the same client session
    where FLUSH TABLES WITH READ LOCK was executed issue SHOW
    SLAVE STATUS command. This command will be blocked waiting
    for rli->data_lock causing a dead lock. Once this happens
    it will not be possible to release the global read lock as
    "UNLOCK TABLES" command has to be issued in the same client
    where global read lock was acquired. This causes the dead
    lock.
    
    Fix:
    
    Existing code holds the rli->data_lock for the whole
    duration of commit operation. Instead of holding the lock
    for entire commit duration the code has been restructured in
    such a way that the lock is held only during the period when
    rli object is being updated.
    f42e9f8f
    Bug#19843808: DEADLOCK ON FLUSH TABLES WITH READ LOCK + SHOW
    s.sujatha authored
    SLAVE STATUS
    
    Problem:
    
    If a client thread on an slave does FLUSH TABLES WITH READ
    LOCK; then master does some updates, SHOW SLAVE STATUS in
    the same client will be blocked.
    
    Analysis:
    
    Execute FLUSH TABLES WITH READ LOCK on slave and at the same
    time execute a DML on the master. Then the DML should be
    made to stop at a state "Waiting for commit lock". This
    state means that sql thread is holding rli->data_lock and
    waiting for MDL_COMMIT lock. Now in the same client session
    where FLUSH TABLES WITH READ LOCK was executed issue SHOW
    SLAVE STATUS command. This command will be blocked waiting
    for rli->data_lock causing a dead lock. Once this happens
    it will not be possible to release the global read lock as
    "UNLOCK TABLES" command has to be issued in the same client
    where global read lock was acquired. This causes the dead
    lock.
    
    Fix:
    
    Existing code holds the rli->data_lock for the whole
    duration of commit operation. Instead of holding the lock
    for entire commit duration the code has been restructured in
    such a way that the lock is held only during the period when
    rli object is being updated.
Loading