在我的轨道项目中,我使用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有帮助 –