在我的軌道項目中,我使用sidekiq處理耗時的任務,但在sidekiq記錄一個錯誤:的ActiveRecord :: StatementInvalid:Mysql2 ::錯誤:鎖等待超時超標
ActiveRecord::StatementInvalid: Mysql2::Error: Lock wait timeout exceeded; try restarting transaction: UPDATE `marker_layers` SET `show_fields` = 'title,desc', `sort_col` = 'title,desc', `updated_at` = '2016-05-17 07:36:02' WHERE `marker_layers`.`id` = 16021210
Processor: iZ23edse84Z:29310
# Options here can still be overridden by cmd line args.
# setsid sidekiq -d -C config/sidekiq.yml -e production
---
:concurrency: 5
:pidfile: tmp/pids/sidekiq.pid
:logfile: log/sidekiq.log
staging:
:concurrency: 10
production:
:concurrency: 40
:queues:
- ['critical', 3]
- ['default', 2]
- ['low', 1]
的database.yml
production:
adapter: mysql2
encoding: utf8mb4
collation: utf8mb4_bin
reconnect: false
database: database_name
pool: 48
username: password
password: password
host: locahost
很可能多個工作人員嘗試更新相同的數據庫行,並在等待訪問時出現一些超時。根據你的信息,我們不能說更多。您應該重新檢查您的代碼是否存在競爭條件並查看死鎖的來源... – averell
您可能會發現http://stackoverflow.com/questions/6000336/how-to-debug-lock-wait-timeout-exceeded有幫助 –