gh-ost Refer to this document for switching order :#82
Suppose now operating DDL on table a, three temporary tables _a_del, _a_gho, and_a_ghc will be generated.
rename operation is: rename a to _a_del, _a_gho to a,
lock table statement is: lock table a write, _a_del write
According to the order of acquiring the lock:
first acquire the _a_del table lock,
then _a_gho table lock ,
and finally the a table lock.

Thank you!