Waiting for table metadata lock
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Waiting for table metadata lock
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                【問題描述】:Mysql5.6的主從環境,在主庫上添加字段始終添加不了,一直沒有返回值。
【排查分析】:
1、在測試環境上執行沒有問題,很快就返回。因為數據量不大,也就10w左右(線上也是10w左右)
2、在執行alter語句時,在另外的終端通過show processlist發現 有等待TML鎖
3、通過如下sql查線程ID
如果沒有返回值 ,使用下面的sql來查:
select i.trx_mysql_thread_id from information_schema.innodb_trx i,(select id, timefrominformation_schema.processlistwheretime = (select max(time)frominformation_schema.processlistwherestate = 'Waiting for table metadata lock'and substring(info, 1, 5) in ('alter' , 'optim', 'repai', 'lock ', 'drop ', 'creat'))) pwhere timestampdiff(second, i.trx_started, now()) > p.timeand i.trx_mysql_thread_id not in (connection_id(),p.id);根據返回的結果繼續查相關的session:
select * from information_schema.processlist where id=104018;
可以根據情況對該會話進行處理。
轉載于:https://blog.51cto.com/zhaowl/2343516
超強干貨來襲 云風專訪:近40年碼齡,通宵達旦的技術人生總結
以上是生活随笔為你收集整理的Waiting for table metadata lock的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 网络编程7_ multiprocessi
- 下一篇: Ivan Fedorov:用已知无法想象
