Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Scale the workers after_commit #36

Merged
merged 1 commit into from

3 participants

@davidakachaos

This will scale the workers after committing the changes
to the database. This will fix issue #34.

Main point of this is to relax the scaling to happen when
the jobs are in the database. This may also have an effect
on issue #33.

@davidakachaos davidakachaos Scale the workers after_commit
This will scale the workers after committing the changes
to the database. This will fix issue #34.

Main point of this is to relax the scaling to happen when
the jobs are in the database. This may also have an effect 
on issue #33.
87d0354
@pekeler

This would also work around random heroku api errors that so far prevent the delayed job record from being created (not good!). For example, two days ago I got a bunch of Heroku::API::Errors::ErrorWithResponse in my cedar app due to "503 Service Unavailable" in
vendor/bundle/ruby/1.9.1/gems/excon-0.16.10/lib/excon/connection.rb:292:in request_kernel'
vendor/bundle/ruby/1.9.1/gems/excon-0.16.10/lib/excon/connection.rb:103:in
request'
vendor/bundle/ruby/1.9.1/gems/heroku-api-0.3.7/lib/heroku/api.rb:74:in request'
vendor/bundle/ruby/1.9.1/gems/heroku-api-0.3.7/lib/heroku/api/processes.rb:43:in
post_ps_scale'
vendor/bundle/ruby/1.9.1/gems/workless-1.1.1/lib/workless/scalers/heroku_cedar.rb:10:in up'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in
_run__933447152030012228__create__3893371580071494491__callbacks'

Same thing happened 4 days ago. And about a month ago I had a few Excon::Errors::SocketError due to "Connection refused" in
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/socket.rb:41:in connect'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/socket.rb:41:in
block (2 levels) in connect'
/usr/ruby1.9.2/lib/ruby/1.9.1/timeout.rb:57:in timeout'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/socket.rb:40:in
block in connect'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/socket.rb:29:in each'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/socket.rb:29:in
connect'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/ssl_socket.rb:77:in connect'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/socket.rb:16:in
initialize'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/ssl_socket.rb:8:in initialize'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/connection.rb:364:in
new'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/connection.rb:364:in socket'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/connection.rb:192:in
request_kernel'
.bundle/gems/ruby/1.9.1/gems/excon-0.16.10/lib/excon/connection.rb:103:in request'
.bundle/gems/ruby/1.9.1/gems/heroku-api-0.3.7/lib/heroku/api.rb:74:in
request'
.bundle/gems/ruby/1.9.1/gems/heroku-api-0.3.7/lib/heroku/api/processes.rb:9:in get_ps'
.bundle/gems/ruby/1.9.1/gems/workless-1.1.1/lib/workless/scalers/heroku_cedar.rb:18:in
workers'
.bundle/gems/ruby/1.9.1/gems/workless-1.1.1/lib/workless/scalers/heroku_cedar.rb:10:in up'
.bundle/gems/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in
_run__2281942245487434652__create__4582579804209064128__callbacks'

So please merge and release this ASAP! Thanks.

@lostboy lostboy merged commit 59f065a into lostboy:master

1 check passed

Details default The Travis build passed
@lostboy
Owner

Hi guys, ill get a gem release out this week for you

@davidakachaos

Thanks!

@davidakachaos davidakachaos deleted the davidakachaos:switch_to_after_commit branch
@pekeler

Great!

@lostboy
Owner

There you go, let me know if it's all good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 7, 2012
  1. @davidakachaos

    Scale the workers after_commit

    davidakachaos authored
    This will scale the workers after committing the changes
    to the database. This will fix issue #34.
    
    Main point of this is to relax the scaling to happen when
    the jobs are in the database. This may also have an effect 
    on issue #33.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 10 deletions.
  1. +3 −3 lib/workless/scaler.rb
  2. +1 −7 spec/spec_helper.rb
View
6 lib/workless/scaler.rb
@@ -10,9 +10,9 @@ module Scaler
def self.included(base)
base.send :extend, ClassMethods
base.class_eval do
- after_destroy "self.class.scaler.down"
- after_create "self.class.scaler.up"
- after_update "self.class.scaler.down", :unless => Proc.new {|r| r.failed_at.nil? }
+ after_commit "self.class.scaler.down", :on => :destroy
+ after_commit "self.class.scaler.up", :on => :create
+ after_commit "self.class.scaler.down", :on => :update, :unless => Proc.new {|r| r.failed_at.nil? }
end
end
View
8 spec/spec_helper.rb
@@ -8,13 +8,7 @@
module Delayed
module Job
class Delayed::Job::Mock
- def self.after_destroy(method, *args)
- end
-
- def self.after_create(method, *args)
- end
-
- def self.after_update(method, *args)
+ def self.after_commit(method, *args, &block)
end
end
end
Something went wrong with that request. Please try again.