Skip to content

Commit

Permalink
Use non-optimized DelayedJob reserve sql strategy
Browse files Browse the repository at this point in the history
Fixes sql deadlocks when running many quick jobs with multiple workers

Deadlocks happened when DJ was trying to delete finished jobs from the database,
as a result those jobs where run a second time which created duplicate event.

Adresses huginn#977
  • Loading branch information
dsander committed Aug 22, 2015
1 parent c358b4f commit e89601a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ gem 'bundler', '>= 1.5.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'daemons', '~> 1.1.9'
gem 'delayed_job', '~> 4.0.0'
gem 'delayed_job_active_record', '~> 4.0.0'
gem 'delayed_job_active_record', :git => 'https://github.com/cantino/delayed_job_active_record', :branch => 'configurable-reserve-sql-strategy'
gem 'devise', '~> 3.4.0'
gem 'dotenv-rails', '~> 2.0.1'
gem 'em-http-request', '~> 1.1.2'
Expand Down
14 changes: 10 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ GIT
omniauth (~> 1.0)
omniauth-oauth2 (~> 1.1)

GIT
remote: https://github.com/cantino/delayed_job_active_record
revision: 7ede4ea81561a66427f600decb87f6fcdb5b8aa4
branch: configurable-reserve-sql-strategy
specs:
delayed_job_active_record (4.0.3)
activerecord (>= 3.0, < 5.0)
delayed_job (>= 3.0, < 4.1)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -119,9 +128,6 @@ GEM
debug_inspector (0.0.2)
delayed_job (4.0.6)
activesupport (>= 3.0, < 5.0)
delayed_job_active_record (4.0.3)
activerecord (>= 3.0, < 5.0)
delayed_job (>= 3.0, < 4.1)
delorean (2.1.0)
chronic
devise (3.4.1)
Expand Down Expand Up @@ -525,7 +531,7 @@ DEPENDENCIES
coveralls
daemons (~> 1.1.9)
delayed_job (~> 4.0.0)
delayed_job_active_record (~> 4.0.0)
delayed_job_active_record!
delorean
devise (~> 3.4.0)
dotenv-rails (~> 2.0.1)
Expand Down
4 changes: 4 additions & 0 deletions config/initializers/delayed_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ class Delayed::Job
scope :awaiting_retry, ->{ where("failed_at IS NULL AND attempts > 0") }
scope :failed, -> { where("failed_at IS NOT NULL") }
end

Delayed::Backend::ActiveRecord.configure do |config|
config.reserve_sql_strategy = :default_sql
end

0 comments on commit e89601a

Please sign in to comment.