Today, we tried adding an index to a table on a production DB (a RDS Aurora cluster running on MySQL 5.6), and ended up deadlocking the DB. We killed the process when it was pending, trying to acquire the MDL.
I'd like some help understanding why this happened. My understanding is that MySQL 5.6 supports online DDL, in which reads and writes can happen during the operation. I also understand that even with online DLL, the operation still needs to acquire the MDL. However, if the process was still waiting to acquire the MDL, why did the DB deadlock?
Is it possible that because we didn't explicitly set LOCK=NONE
, the operation still ended up acquiring some locks? Would setting LOCK=NONE
prevent a deadlock for happening in the future? If not, is there a way that we can perform the index creation in safe manner, preferably with no downtime?
(I've taken a look at this post, which seems to imply that such operations are safe in 5.6+ due to online DDL).