Skip to content

Commit e1b9686

Browse files
committed
Bug #28774259 : LOCK_ORDER: DEADLOCK INVOLVING MASTER_KEY_ID_MUTEX
Issue: For two threads T1 and T2 where T1 : DROP TABLE t1; T2 : CREATE TABLESPACE encrypt_ts ADD DATAFILE 'encrypt_ts.ibd' ENCRYPTION='Y'; Following is a possible deadlock scenario where : T1 : Holding (mutex on master_key_id_mutex) : Requesting (dict_sys->mutex) T2 : Holding (dict_sys->mutex) : Requesting (mutex on master_key_id_mutex) Fix: In replay_delete_space_log(), take mutex on master_key_id_mutex, after releasing dict_sys->mutex to make sure there is no wait cycle. RB : 20745 Reviewed by : Annamalai Gurusami <annamalai.gurusami@oracle.com>
1 parent e5b9667 commit e1b9686

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

storage/innobase/log/log0ddl.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -1542,11 +1542,6 @@ void Log_DDL::replay_delete_space_log(space_id_t space_id,
15421542
undo::spaces->x_unlock();
15431543
}
15441544

1545-
/* Require the mutex to block key rotation. Please note that
1546-
here we don't know if this tablespace is encrypted or not,
1547-
so just acquire the mutex unconditionally. */
1548-
mutex_enter(&master_key_id_mutex);
1549-
15501545
if (thd != nullptr) {
15511546
/* For general tablespace, MDL on SDI tables is already
15521547
acquired at innobase_drop_tablespace() and for file_per_table
@@ -1556,6 +1551,11 @@ void Log_DDL::replay_delete_space_log(space_id_t space_id,
15561551
mutex_exit(&dict_sys->mutex);
15571552
}
15581553

1554+
/* Require the mutex to block key rotation. Please note that
1555+
here we don't know if this tablespace is encrypted or not,
1556+
so just acquire the mutex unconditionally. */
1557+
mutex_enter(&master_key_id_mutex);
1558+
15591559
DBUG_EXECUTE_IF("ddl_log_replay_delete_space_crash_before_drop",
15601560
DBUG_SUICIDE(););
15611561

0 commit comments

Comments
 (0)