ActiveJob not showing up in Sidekiq queue - ruby-on-rails

ActiveJob assigns don't seem to show up in the sidekiq queues.. But the jobs still get executed.
This is my active_job setup in config/environments/production.rb
config.active_job.queue_adapter = :sidekiq
config.active_job.queue_name_prefix = "faces_#{Rails.env}"
My sidekiq.yml that gets loaded via Capistrano.
---
:concurrency: 5
:queues:
- default
production:
:concurrency: 20
:queues:
- faces_production_default
Sample output when I start to queue a job and check if it's there.
2.6.3 :001 > require 'sidekiq/api'
=> true
2.6.3 :002 > Sidekiq::Queue.new('faces_production_default').count
=> 0
2.6.3 :003 > stats = Sidekiq::Stats.new
=> #<Sidekiq::Stats:0x0000000004dd80e8 #stats={:processed=>48, :failed=>0, :scheduled_size=>1, :retry_size=>0, :dead_size=>0, :processes_size=>2, :default_queue_latency=>0, :workers_size=>0, :enqueued=>0}>
2.6.3 :004 > stats.queues
=> {"default"=>0, "faces_production_default"=>0, "mailers"=>0}
2.6.3 :005 > FaceParserJob.set(wait: 5.minutes).perform_later(200)
Enqueued FaceParserJob (Job ID: 9848e560-dbf5-4fc0-a3c3-6b8f00164a8a) to Sidekiq(faces_production_default) at 2019-04-28 15:16:25 UTC with arguments: 200
=> #<FaceParserJob:0x0000000004f19b00 #arguments=[200], #job_id="9848e560-dbf5-4fc0-a3c3-6b8f00164a8a", #queue_name="faces_production_default", #priority=nil, #executions=0, #scheduled_at=1556464585.1313956, #provider_job_id="43d2c83a305411bfda6626b1">
2.6.3 :006 > Sidekiq::Queue.new('faces_production_default').count
=> 0
Thing is if I monitor the sidekiq.log in 5 minutes it does execute the job. What am I doing wrong?

Job is put into a queue only when it's being "launched", until then - it waits in scheduled queue, you can check with
Sidekiq::ScheduledSet.new.size

Related

ActiveJob and Sidekiq jobs stuck in enqueued

So I just migrated to Rails 5.1.4 and I'm trying to make Active Job work, but the jobs are just stuck in the queue and never processed.
rails: 5.1.4
ruby: 2.4.3
sidekiq: 5.0.5
redis: 4.0.1
sidekiq.yml
---
:verbose: true
:concurrency: 5
:timeout: 60
development:
:concurrency: 25
staging:
:concurrency: 50
production:
:concurrency: 5
:queues:
- default
- [high_priority, 2]
sidekiq.rb
Sidekiq.configure_server do |config|
config.redis = {url: ENV['ACTIVE_JOB_URL'], network_timeout: 5}
end
Sidekiq.configure_client do |config|
config.redis = {url: ENV['ACTIVE_JOB_URL'], network_timeout: 5}
end
Here the is how I perform the task from the rails console:
TestJob.perform_later
TestJob.rb content:
class TestJob < ApplicationJob
queue_as :default
def perform(*args)
Rails.logger.debug "#{self.class.name}: I'm performing my job with arguments: #{args.inspect}"
end
end
The jobs are just stuck in the queue and never processed:
Have you started the worker, eg in development it might be:
bundle exec sidekiq
If in production Heroku should do this for you, if you have configured your Procfile, eg:
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq
You can also use your Procfile in development with foreman, eg:
foreman start -f Procfile

Why are my Open-uri/Nokogiri requests taking longer (>30s) on my Heroku rails console than on my local rails console (<1s)?

I have rails 4.2.1 installed.
On my local rails console:
2.2.1 :001 > require 'nokogiri'
=> true
2.2.1 :002 > require 'open-uri'
=> true
2.2.1 :003 > doc = Nokogiri::HTML(open('http://sfbay.craigslist.org/search/fuo?srchType=T&query=knoll'))
And the response time is ~ 1s.
On the heroku rails console, I just run:
doc = Nokogiri::HTML(open('http://sfbay.craigslist.org/search/fuo?srchType=T&query=knoll'))
And the response time is over 30s.
I get what I'm expecting in both places, but the response time on Heroku causes my app to time out in production.

Ruby on Rails SNMP gem - no response from device

I'm using the SNMP gem in a Rails app to control a Cisco switch. The "get" features of the Gem work, and I can retrieve values from the devices, but the "set" feature isn't working so well...
From the command line, the SNMP commands work properly:
bash-4.1# snmpset -v2c -c private-string 192.168.3.1 .1.3.6.1.2.1.2.2.1.7.11 i 2
IF-MIB::ifAdminStatus.11 = INTEGER: down(2)
bash-4.1#
But when I try to set the same OID using the Gem, I get "no response from 192.168.3.1"
In both the actual app and in IRB:
bash-4.1# irb
2.0.0-p0 :001 > require 'snmp'
=> true
2.0.0-p0 :002 > include SNMP
=> Object
2.0.0-p0 :003 > SNMP::Manager.open(:host => "192.168.3.1", :community => "private-string") do |manager|
2.0.0-p0 :004 > varbind = VarBind.new("1.3.6.1.2.1.2.2.1.7.11", "2")
2.0.0-p0 :005?> manager.set(varbind)
2.0.0-p0 :006?> end
SNMP::RequestTimeout: host 192.168.3.1 not responding
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/snmp-1.1.1/lib/snmp/manager.rb:293:in `set'
from (irb):5:in `block in irb_binding'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/snmp-1.1.1/lib/snmp/manager.rb:205:in `open'
from (irb):3
from /usr/local/rvm/rubies/ruby-2.0.0-p0/bin/irb:16:in `<main>'
2.0.0-p0 :007 > exit
I can run the snmpset from the command line on the same machine, and it works correctly, but not using the gem.
Try varbind = VarBind.new("1.3.6.1.2.1.2.2.1.7.11", SNMP::Integer.new(2)) so that the varbind type is correct.

Why is DelayedJob is ignoring delayed_job_config.rb?

I have the following:
/config/delayed_job_config.rb
# Enable DelayedJob Logging
Delayed::Worker.logger = Rails.logger
Delayed::Worker.logger.auto_flushing = 1
# Do not delete failed jobs (default is true)
Delayed::Worker.destroy_failed_jobs = false
# Dont wait so long between jobs
Delayed::Worker.read_ahead = 100 # default was 5
Delayed::Worker.sleep_delay = 1 #default was 5
Problem here is the settings are not being used:
$ rails c
Loading development environment (Rails 3.2.5)
1.9.3-p125 :001 > Delayed::Worker.read_ahead
=> 5
1.9.3-p125 :002 > Delayed::Worker.sleep_delay
=> 5
Any ideas what's wrong here? Thanks
The configuration goes in:
config/initializers/delayed_job_config.rb
Documentation is here.

Resque Workers not working on the right DB

I have Resque set to use database 6 like this:
Resque.redis = "localhost:6779:6"
I then started my resque as follows:
$ RAILS_ENV=test PIDFILE=./resque.pid QUEUE=* rake resque:work
When I check workers, there are none:
pry(main)> Resque.redis = "localhost:6779:6"
=> "localhost:6779:6"
pry(main)> Resque.workers
=> []
But when I check on database 0, I can see it is there:
pry(main)> Resque.redis = "localhost:6779:0"
=> "localhost:6379:0"
pry(main)> Resque.workers
=> [#<Worker ub40:6352:*>]
How do I make my worker use a different database?
I was able to get it working. It turns out there was resque-scheduler rake task that was overriding Resque's redis setter.

Resources