mysql 常見錯誤
1、
鎖等待超時。是當前事務在等待其它事務釋放鎖資源造成的。可以找出鎖資源競爭的表和語句,優化你的SQL,創建索引等,如果還是不行,可以適當減少並發線程數。
2、
你的事務在等待給某個表加鎖時超時了,估計是表正被另的進程鎖住一直沒有釋放。
可以用 SHOW INNODB STATUS/G; 看一下鎖的情況。
3、搜索解決 之道
在管理 節點的[ndbd default]
區加:
TransactionDeadLockDetectionTimeOut=10000(設置 為10秒)默認是1200(1.2秒)
4、
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放棄行級鎖的超時時間。
mysql 常見錯誤