-
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
Karthik Kamath authoredGTID 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