Skip to content
  • Karthik Kamath's avatar
    4f2a1b2f
    BUG#28293047: LOCK_GRANT AND LOCK_OPEN CAN DEADLOCK ON A · 4f2a1b2f
    Karthik Kamath authored
                  GTID SLAVE
    
    ANALYSIS:
    =========
    In a MySQL server started with GTID_MODE=ON, concurrent
    running of the statements DROP USER and SELECT on
    I_S.columns table on multiple threads could lead to a
    deadlock.
    
    The INFORMATION_SCHEMA.COLUMNS table provides information
    about columns in tables.
    
    DROP USER acquires LOCK_GRANT in mysql_drop_user() and
    later acquires LOCK_OPEN on mysql.gtid_executed table.
    SELECT on I_S tables acquires LOCK_OPEN on the tables it
    tries to fetch information from, in
    fill_schema_table_from_frm() and later acquires
    LOCK_GRANT. Since the lock order is opposite in these two
    queries, a deadlock occurs.
    
    SELECT on I_S table takes LOCK_OPEN before opening the
    table in open_table_from_share() and it is released only
    after releasing LOCK_GRANT. LOCK_GRANT is acquired for
    fetching the necessary column information from the tables.
    So LOCK_OPEN was being held for a duration longer than
    necessary.
    
    FIX:
    ====
    For SELECT on I_S tables, release LOCK_OPEN immediately
    after open_table_from_share() returns.
    
    Change-Id: I04d4e1bc38d4de74d0b99bad3dba43d9cce96168
    4f2a1b2f
    BUG#28293047: LOCK_GRANT AND LOCK_OPEN CAN DEADLOCK ON A
    Karthik Kamath authored
                  GTID SLAVE
    
    ANALYSIS:
    =========
    In a MySQL server started with GTID_MODE=ON, concurrent
    running of the statements DROP USER and SELECT on
    I_S.columns table on multiple threads could lead to a
    deadlock.
    
    The INFORMATION_SCHEMA.COLUMNS table provides information
    about columns in tables.
    
    DROP USER acquires LOCK_GRANT in mysql_drop_user() and
    later acquires LOCK_OPEN on mysql.gtid_executed table.
    SELECT on I_S tables acquires LOCK_OPEN on the tables it
    tries to fetch information from, in
    fill_schema_table_from_frm() and later acquires
    LOCK_GRANT. Since the lock order is opposite in these two
    queries, a deadlock occurs.
    
    SELECT on I_S table takes LOCK_OPEN before opening the
    table in open_table_from_share() and it is released only
    after releasing LOCK_GRANT. LOCK_GRANT is acquired for
    fetching the necessary column information from the tables.
    So LOCK_OPEN was being held for a duration longer than
    necessary.
    
    FIX:
    ====
    For SELECT on I_S tables, release LOCK_OPEN immediately
    after open_table_from_share() returns.
    
    Change-Id: I04d4e1bc38d4de74d0b99bad3dba43d9cce96168
Loading