sidekiq 3.2.5 → 3.2.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58e23b8c86c8a85feffbcd31949baf897e08b8db
4
- data.tar.gz: 08fdfb51c221a0f441a84ecc1dfc8a926a9cb93e
3
+ metadata.gz: b589aea06c5a40ae600d780a9ae6eb89766d8195
4
+ data.tar.gz: 0648e289e18aa26e8887bb5041a40fb2886080f5
5
5
  SHA512:
6
- metadata.gz: cda9f58863db3b718f0688c8cc3de8add91b25b6d75e2c7e4f4fba529a082dd69a7a5ab7ae28573aba6e27c5377883c22098c238d73fec98da86bb3c705a317b
7
- data.tar.gz: b06be66eccdca4b5b3db27a35b570279a511e9640f19ab2cb023cc8c224ce95cd29408d99947e0c8dbb0f6bc1665cd464355132de746d57c7b1877a02a8dfcaa
6
+ metadata.gz: 8f02a8ad25930c5123c8a6c52a0d173bd452e8442b6642fe02743ed7b5f1f29f791208dde1e4de257fe126e2909d072f934d28f5517334c350f87bcfab29eee9
7
+ data.tar.gz: c28264360d2ddd2d0e868d17d8e3b0b8327f8cf6b84a3a845199be63bfb7d57ce2e85596d981da7e7abb8f71d6290b9ade4364ef8157ad99663edbfa1cdb24df
@@ -6,6 +6,7 @@ rvm:
6
6
  - rbx-2
7
7
  - 2.0.0
8
8
  - 2.1
9
+ - 2.2
9
10
  matrix:
10
11
  allow_failures:
11
12
  - rvm: rbx-2
data/Changes.md CHANGED
@@ -1,7 +1,15 @@
1
+ HEAD
2
+ -----------
3
+
4
+ - Deprecate delay extension for ActionMailer 4.2+ . [#1933]
5
+ - Poll interval tuning now accounts for dead processes [epchris, #1984]
6
+ - Add non-production environment to Web UI page titles [JacobEvelyn, #2004]
7
+
1
8
  3.2.5
2
9
  -----------
3
10
 
4
- - Lock Celluloid to 0.15.2 due to bugs in 0.16.0.
11
+ - Lock Celluloid to 0.15.2 due to bugs in 0.16.0. This prevents the
12
+ "hang on shutdown" problem with Celluloid 0.16.0.
5
13
 
6
14
  3.2.4
7
15
  -----------
@@ -3,6 +3,20 @@ Sidekiq Pro Changelog
3
3
 
4
4
  Please see [http://sidekiq.org/pro](http://sidekiq.org/pro) for more details and how to buy.
5
5
 
6
+ 1.9.1
7
+ -----------
8
+
9
+ - **SECURITY** Fix XSS in batch description, thanks to intercom.io for reporting the
10
+ issue. If you don't use batch descriptions, you don't need the fix.
11
+
12
+ 1.9.0
13
+ -----------
14
+
15
+ - Add new expiring jobs feature [#1982]
16
+ - Show batch expiration on Batch details page [#1981]
17
+ - Add '$' batch success token to the pubsub support. [#1953]
18
+
19
+
6
20
  1.8.0
7
21
  -----------
8
22
 
data/README.md CHANGED
@@ -27,8 +27,7 @@ Requirements
27
27
  I test with the latest MRI (2.1, 2.0) and JRuby versions (1.7). Other versions/VMs
28
28
  are untested but might work fine. MRI 1.9 is no longer supported.
29
29
 
30
- The last two major Rails releases (3.2 and 4.0) are officially supported, other
31
- versions might work fine.
30
+ All Rails releases starting from 3.2 are officially supported.
32
31
 
33
32
  Redis 2.4 or greater is required.
34
33
 
@@ -545,32 +545,53 @@ module Sidekiq
545
545
  class ProcessSet
546
546
  include Enumerable
547
547
 
548
+ def initialize(clean_plz=true)
549
+ self.class.cleanup if clean_plz
550
+ end
551
+
552
+ # Cleans up dead processes recorded in Redis.
553
+ # Returns the number of processes cleaned.
554
+ def self.cleanup
555
+ count = 0
556
+ Sidekiq.redis do |conn|
557
+ procs = conn.smembers('processes').sort
558
+ heartbeats = conn.pipelined do
559
+ procs.each do |key|
560
+ conn.hget(key, 'info')
561
+ end
562
+ end
563
+
564
+ # the hash named key has an expiry of 60 seconds.
565
+ # if it's not found, that means the process has not reported
566
+ # in to Redis and probably died.
567
+ to_prune = []
568
+ heartbeats.each_with_index do |beat, i|
569
+ to_prune << procs[i] if beat.nil?
570
+ end
571
+ count = conn.srem('processes', to_prune) unless to_prune.empty?
572
+ end
573
+ count
574
+ end
575
+
548
576
  def each(&block)
549
- procs = Sidekiq.redis { |conn| conn.smembers('processes') }
577
+ procs = Sidekiq.redis { |conn| conn.smembers('processes') }.sort
550
578
 
551
- to_prune = []
552
- sorted = procs.sort
553
579
  Sidekiq.redis do |conn|
554
580
  # We're making a tradeoff here between consuming more memory instead of
555
581
  # making more roundtrips to Redis, but if you have hundreds or thousands of workers,
556
582
  # you'll be happier this way
557
583
  result = conn.pipelined do
558
- sorted.each do |key|
584
+ procs.each do |key|
559
585
  conn.hmget(key, 'info', 'busy', 'beat')
560
586
  end
561
587
  end
562
588
 
563
589
  result.each_with_index do |(info, busy, at_s), i|
564
- # the hash named key has an expiry of 60 seconds.
565
- # if it's not found, that means the process has not reported
566
- # in to Redis and probably died.
567
- (to_prune << sorted[i]; next) if info.nil?
568
590
  hash = Sidekiq.load_json(info)
569
591
  yield Process.new(hash.merge('busy' => busy.to_i, 'beat' => at_s.to_f))
570
592
  end
571
593
  end
572
594
 
573
- Sidekiq.redis {|conn| conn.srem('processes', to_prune) } unless to_prune.empty?
574
595
  nil
575
596
  end
576
597
 
@@ -138,11 +138,11 @@ module Sidekiq
138
138
  end
139
139
  when 'TTIN'
140
140
  Thread.list.each do |thread|
141
- Sidekiq.logger.info "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}"
141
+ Sidekiq.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}"
142
142
  if thread.backtrace
143
- Sidekiq.logger.info thread.backtrace.join("\n")
143
+ Sidekiq.logger.warn thread.backtrace.join("\n")
144
144
  else
145
- Sidekiq.logger.info "<no backtrace available>"
145
+ Sidekiq.logger.warn "<no backtrace available>"
146
146
  end
147
147
  end
148
148
  end
@@ -17,7 +17,20 @@ module Sidekiq
17
17
  msg = target.public_send(method_name, *args)
18
18
  # The email method can return nil, which causes ActionMailer to return
19
19
  # an undeliverable empty message.
20
- msg.deliver if msg && (msg.to || msg.cc || msg.bcc) && msg.from
20
+ deliver(msg) if msg && (msg.to || msg.cc || msg.bcc) && msg.from
21
+ end
22
+
23
+ private
24
+
25
+ def deliver(msg)
26
+ if msg.respond_to?(:deliver_now)
27
+ ActiveSupport::Deprecation.warn('`ActionMailer.delay.method` is deprecated. Use `ActionMailer.method.deliver_later` instead and configure ActiveJob to use Sidekiq.')
28
+ # Rails 4.2/5.0
29
+ msg.deliver_now
30
+ else
31
+ # Rails 3.2/4.0/4.1
32
+ msg.deliver
33
+ end
21
34
  end
22
35
  end
23
36
 
@@ -52,6 +52,7 @@ module Sidekiq
52
52
  manager.wait(:shutdown) if manager.alive?
53
53
 
54
54
  # Requeue everything in case there was a worker who grabbed work while stopped
55
+ # This call is a no-op in Sidekiq but necessary for Sidekiq Pro.
55
56
  Sidekiq::Fetcher.strategy.bulk_requeue([], @options)
56
57
 
57
58
  stop_heartbeat
@@ -49,7 +49,7 @@ module Sidekiq
49
49
 
50
50
  stats(worker, msg, queue) do
51
51
  Sidekiq.server_middleware.invoke(worker, msg, queue) do
52
- worker.perform(*cloned(msg['args']))
52
+ execute_job(worker, cloned(msg['args']))
53
53
  end
54
54
  end
55
55
  rescue Sidekiq::Shutdown
@@ -71,6 +71,10 @@ module Sidekiq
71
71
  "<Processor##{object_id.to_s(16)}>"
72
72
  end
73
73
 
74
+ def execute_job(worker, cloned_args)
75
+ worker.perform(*cloned_args)
76
+ end
77
+
74
78
  private
75
79
 
76
80
  def thread_identity
@@ -1,6 +1,7 @@
1
1
  require 'sidekiq'
2
2
  require 'sidekiq/util'
3
3
  require 'sidekiq/actor'
4
+ require 'sidekiq/api'
4
5
 
5
6
  module Sidekiq
6
7
  module Scheduled
@@ -8,10 +9,10 @@ module Sidekiq
8
9
  INITIAL_WAIT = 10
9
10
 
10
11
  ##
11
- # The Poller checks Redis every N seconds for messages in the retry or scheduled
12
+ # The Poller checks Redis every N seconds for jobs in the retry or scheduled
12
13
  # set have passed their timestamp and should be enqueued. If so, it
13
- # just pops the message back onto its original queue so the
14
- # workers can pick it up like any other message.
14
+ # just pops the job back onto its original queue so the
15
+ # workers can pick it up like any other job.
15
16
  class Poller
16
17
  include Util
17
18
  include Actor
@@ -23,8 +24,8 @@ module Sidekiq
23
24
  initial_wait if first_time
24
25
 
25
26
  begin
26
- # A message's "score" in Redis is the time at which it should be processed.
27
- # Just check Redis for the set of messages with a timestamp before now.
27
+ # A job's "score" in Redis is the time at which it should be processed.
28
+ # Just check Redis for the set of jobs with a timestamp before now.
28
29
  now = Time.now.to_f.to_s
29
30
  Sidekiq.redis do |conn|
30
31
  SETS.each do |sorted_set|
@@ -32,14 +33,14 @@ module Sidekiq
32
33
  # We need to go through the list one at a time to reduce the risk of something
33
34
  # going wrong between the time jobs are popped from the scheduled queue and when
34
35
  # they are pushed onto a work queue and losing the jobs.
35
- while message = conn.zrangebyscore(sorted_set, '-inf', now, :limit => [0, 1]).first do
36
+ while job = conn.zrangebyscore(sorted_set, '-inf', now, :limit => [0, 1]).first do
36
37
 
37
38
  # Pop item off the queue and add it to the work queue. If the job can't be popped from
38
39
  # the queue, it's because another process already popped it so we can move on to the
39
40
  # next one.
40
- if conn.zrem(sorted_set, message)
41
- Sidekiq::Client.push(Sidekiq.load_json(message))
42
- logger.debug { "enqueued #{sorted_set}: #{message}" }
41
+ if conn.zrem(sorted_set, job)
42
+ Sidekiq::Client.push(Sidekiq.load_json(job))
43
+ logger.debug { "enqueued #{sorted_set}: #{job}" }
43
44
  end
44
45
  end
45
46
  end
@@ -75,7 +76,9 @@ module Sidekiq
75
76
  # We only do this if poll_interval is unset (the default).
76
77
  def poll_interval
77
78
  Sidekiq.options[:poll_interval] ||= begin
78
- pcount = Sidekiq.redis {|c| c.scard('processes') } || 1
79
+ ps = Sidekiq::ProcessSet.new
80
+ pcount = ps.size
81
+ pcount = 1 if pcount == 0
79
82
  pcount * 15
80
83
  end
81
84
  end
@@ -153,7 +153,7 @@ module Sidekiq
153
153
  while job = jobs.shift do
154
154
  worker = new
155
155
  worker.jid = job['jid']
156
- worker.perform(*job['args'])
156
+ execute_job(worker, job['args'])
157
157
  end
158
158
  end
159
159
 
@@ -163,7 +163,11 @@ module Sidekiq
163
163
  job = jobs.shift
164
164
  worker = new
165
165
  worker.jid = job['jid']
166
- worker.perform(*job['args'])
166
+ execute_job(worker, job['args'])
167
+ end
168
+
169
+ def execute_job(worker, args)
170
+ worker.perform(*args)
167
171
  end
168
172
  end
169
173
 
@@ -1,3 +1,3 @@
1
1
  module Sidekiq
2
- VERSION = "3.2.5"
2
+ VERSION = "3.2.6"
3
3
  end
@@ -133,14 +133,13 @@ module Sidekiq
133
133
  end
134
134
 
135
135
  get "/retries/:key" do
136
- halt 404 unless params['key']
137
136
  @retry = Sidekiq::RetrySet.new.fetch(*parse_params(params['key'])).first
138
137
  redirect "#{root_path}retries" if @retry.nil?
139
138
  erb :retry
140
139
  end
141
140
 
142
141
  post '/retries' do
143
- halt 404 unless params['key']
142
+ redirect request.path unless params['key']
144
143
 
145
144
  params['key'].each do |key|
146
145
  job = Sidekiq::RetrySet.new.fetch(*parse_params(key)).first
@@ -160,7 +159,6 @@ module Sidekiq
160
159
  end
161
160
 
162
161
  post "/retries/:key" do
163
- halt 404 unless params['key']
164
162
  job = Sidekiq::RetrySet.new.fetch(*parse_params(params['key'])).first
165
163
  retry_or_delete_or_kill job, params if job
166
164
  redirect_with_query("#{root_path}retries")
@@ -174,14 +172,13 @@ module Sidekiq
174
172
  end
175
173
 
176
174
  get "/scheduled/:key" do
177
- halt 404 unless params['key']
178
175
  @job = Sidekiq::ScheduledSet.new.fetch(*parse_params(params['key'])).first
179
176
  redirect "#{root_path}scheduled" if @job.nil?
180
177
  erb :scheduled_job_info
181
178
  end
182
179
 
183
180
  post '/scheduled' do
184
- halt 404 unless params['key']
181
+ redirect request.path unless params['key']
185
182
 
186
183
  params['key'].each do |key|
187
184
  job = Sidekiq::ScheduledSet.new.fetch(*parse_params(key)).first
@@ -21,7 +21,7 @@ module Sidekiq
21
21
  end
22
22
 
23
23
  def locale
24
- lang = (request.env["HTTP_ACCEPT_LANGUAGE"] || 'en')[0,2]
24
+ lang = (request.env["HTTP_ACCEPT_LANGUAGE"] || 'en').split(',')[0].downcase
25
25
  strings[lang] ? lang : 'en'
26
26
  end
27
27
 
@@ -172,5 +172,11 @@ module Sidekiq
172
172
  redirect url
173
173
  end
174
174
  end
175
+
176
+ def environment_title_prefix
177
+ environment = Sidekiq.options[:environment] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
178
+
179
+ "[#{environment.upcase}] " unless environment == "production"
180
+ end
175
181
  end
176
182
  end
@@ -469,7 +469,7 @@ class TestApi < Sidekiq::Test
469
469
  end
470
470
 
471
471
  ps = Sidekiq::ProcessSet.new
472
- assert_equal 3, ps.size
472
+ assert_equal 1, ps.size
473
473
  assert_equal 1, ps.to_a.size
474
474
  end
475
475
 
@@ -39,6 +39,12 @@ class TestProcessor < Sidekiq::Test
39
39
  assert_equal 1, $invokes
40
40
  end
41
41
 
42
+ it 'executes a worker as expected' do
43
+ worker = Minitest::Mock.new
44
+ worker.expect(:perform, nil, [1, 2, 3])
45
+ @processor.execute_job(worker, [1, 2, 3])
46
+ end
47
+
42
48
  it 'passes exceptions to ExceptionHandler' do
43
49
  actor = Minitest::Mock.new
44
50
  actor.expect(:real_thread, nil, [nil, Thread])
@@ -261,5 +261,11 @@ class TestTesting < Sidekiq::Test
261
261
  assert_equal 1, FirstWorker.count
262
262
  assert_equal 1, SecondWorker.count
263
263
  end
264
+
265
+ it 'can execute a job' do
266
+ worker = Minitest::Mock.new
267
+ worker.expect(:perform, nil, [1, 2, 3])
268
+ DirectWorker.execute_job(worker, [1, 2, 3])
269
+ end
264
270
  end
265
271
  end
@@ -1,7 +1,7 @@
1
1
  <!doctype html>
2
2
  <html>
3
3
  <head>
4
- <title><%= Sidekiq::NAME %></title>
4
+ <title><%= environment_title_prefix %><%= Sidekiq::NAME %></title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1.0" />
6
6
  <link href="<%= root_path %>stylesheets/bootstrap.css" media="screen" rel="stylesheet" type="text/css" />
7
7
  <link href="<%= root_path %>stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.5
4
+ version: 3.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-10 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -245,8 +245,8 @@ files:
245
245
  - web/assets/javascripts/locales/jquery.timeago.bg.js
246
246
  - web/assets/javascripts/locales/jquery.timeago.bs.js
247
247
  - web/assets/javascripts/locales/jquery.timeago.ca.js
248
+ - web/assets/javascripts/locales/jquery.timeago.cs.js
248
249
  - web/assets/javascripts/locales/jquery.timeago.cy.js
249
- - web/assets/javascripts/locales/jquery.timeago.cz.js
250
250
  - web/assets/javascripts/locales/jquery.timeago.da.js
251
251
  - web/assets/javascripts/locales/jquery.timeago.de.js
252
252
  - web/assets/javascripts/locales/jquery.timeago.el.js