Phantom Metadata Lock -- MySQL 5.5, 5.6, and 5.7.x

Has anyone run into the MySQL bug with the phantom “Waiting for table metadata lock” bug before? We get them every now and then where there is no valid lock (and no traffic altogether) and yet, it hangs as if the table is in lock status. No bueno.

The solution thus far has been to restart the master daemon to “clear out” the phantom locks… This is not always possible with OLTP systems, however.

It has appeared in 5.5, 5.6 and 5.7…