mysql 常見錯誤

Lock wait timeout exceeded; try restarting transaction一些信息併發

一、ide

鎖等待超時。是當前事務在等待其它事務釋放鎖資源形成的。能夠找出鎖資源競爭的表和語句,優化你的SQL,建立索引等,若是仍是不行,能夠適當減小併發線程數。優化


二、spa

你的事務在等待給某個表加鎖時超時了,估計是表正被另的進程鎖住一直沒有釋放。線程

能夠用 SHOW INNODB STATUS/G; 看一下鎖的狀況。rest

三、搜索解決 之道索引

在管理 節點的[ndbd default]進程

區加:事務

TransactionDeadLockDetectionTimeOut=10000(設置 爲10秒)默認是1200(1.2秒)資源

四、

InnoDB會自動的檢測死鎖進行回滾,或者終止死鎖的狀況。

引用

InnoDB automatically detects transaction deadlocks and rolls back a transaction or transactions to break the deadlock. 

InnoDB tries to pick small transactions to roll back, where the size of a transaction is determined by the number of rows inserted, updated, or deleted.

若是參數innodb_table_locks=1而且autocommit=0時,InnoDB會留意表的死鎖,和MySQL層面的行級鎖。另外,InnoDB不會檢測MySQL的Lock Tables命令和其餘存儲引擎死鎖。

你應該設置innodb_lock_wait_timeout來解決這種狀況。

innodb_lock_wait_timeout是Innodb放棄行級鎖的超時時間。

相關文章
相關標籤/搜索