• Dmitry Lenev's avatar
    Patch that refactors global read lock implementation and fixes · 6bf6272f
    Dmitry Lenev authored
    bug #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ
    LOCK" and bug #54673 "It takes too long to get readlock for
    'FLUSH TABLES WITH READ LOCK'".
    
    The first bug manifested itself as a deadlock which occurred
    when a connection, which had some table open through HANDLER
    statement, tried to update some data through DML statement
    while another connection tried to execute FLUSH TABLES WITH
    READ LOCK concurrently.
    
    What happened was that FTWRL in the second connection managed
    to perform first step of GRL acquisition and thus blocked all
    upcoming DML. After that it started to wait for table open
    through HANDLER statement to be flushed. When the first connection
    tried to execute DML it has started to wait for GRL/the second
    connection creating deadlock.
    
    The second bug manifested itself as starvation of FLUSH TABLES
    WITH READ LOCK statements in cases when there was a constant
    stream of concurrent DML statements (in two or more
    connections).
    
    ...
    6bf6272f
sql_admin.cc 35.6 KB