sidekiq 2.17.1 → 2.17.2

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: 24bfd443535efddca7164e0784c5317d25487673
4
- data.tar.gz: 24e85e77a30f1e6dba72ae0a965fa63b4b8b5b33
3
+ metadata.gz: a9ab8dfc9a5a77f21aaf9fa21ba6be7e7660246c
4
+ data.tar.gz: 5898594eec812b1b4702ef9807c0e94216172f91
5
5
  SHA512:
6
- metadata.gz: 8b031f54208e373dcf35a2c4da99a8756b6c5cfa8fe984e9bce4841d01240780dac4f052cdef86474788c23f317f9f54415bb3e2ce9cd1de868a621767291ea2
7
- data.tar.gz: b66143b6db4ba974f8d9846728e109b27c3fb95fe3e8aa5182698e2c539e0a4d729b26da3e776d619b72d5c850c8e45e491cd186394d847f5e3cbb0d75e9479f
6
+ metadata.gz: 2fdca306a973f6a4e42c6f436d18c720dc7228c34cdcb1dc0b62c37b0be4d70940031e1b1f760b40f04bc203a2a571d289d6c1952a06efe932df13e691535292
7
+ data.tar.gz: cbc8fa44394a552fbc1ecb97d8bfb1ad82a841821a8cc2c83b17db517d23f038d5d55567059e495e43d632179fdb64d2064967f70f6f79528dc4b31ac0d11f12
@@ -6,6 +6,7 @@ rvm:
6
6
  - jruby-19mode
7
7
  - rbx
8
8
  - 2.0.0
9
+ - 2.1.0
9
10
  matrix:
10
11
  allow_failures:
11
12
  - rvm: jruby-19mode
data/Changes.md CHANGED
@@ -1,3 +1,10 @@
1
+ 2.17.2
2
+ -----------
3
+
4
+ - Fix race condition in bulk requeue during shutdown [#1406]
5
+ - Fix bug where strictly prioritized queues might be processed out of
6
+ order [#1408]
7
+
1
8
  2.17.1
2
9
  -----------
3
10
 
@@ -3,6 +3,12 @@ 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
+ HEAD
7
+ -----------
8
+
9
+ - Add batch progress bar to batch detail page. [#1398]
10
+
11
+
6
12
  1.4.0
7
13
  -----------
8
14
 
@@ -10,10 +10,12 @@ module Sidekiq
10
10
  Sidekiq.redis { |conn| conn.get("stat:failed") }.to_i
11
11
  end
12
12
 
13
- def reset
13
+ def reset(*stats)
14
+ all = %w(failed processed)
15
+ stats = stats.empty? ? all : all & stats.flatten.compact.map(&:to_s)
16
+
14
17
  Sidekiq.redis do |conn|
15
- conn.set("stat:failed", 0)
16
- conn.set("stat:processed", 0)
18
+ stats.each { |stat| conn.set("stat:#{stat}", 0) }
17
19
  end
18
20
  end
19
21
 
@@ -174,13 +174,15 @@ module Sidekiq
174
174
  end
175
175
 
176
176
  def setup_options(args)
177
- cli = parse_options(args)
178
- set_environment cli[:environment]
177
+ opts = parse_options(args)
178
+ set_environment opts[:environment]
179
179
 
180
- cfile = cli[:config_file]
180
+ cfile = opts[:config_file]
181
+ opts = parse_config(cfile).merge(opts) if cfile
182
+
183
+ opts[:strict] = true if opts[:strict].nil?
181
184
 
182
- config = (cfile ? parse_config(cfile) : {})
183
- options.merge!(config.merge(cli))
185
+ options.merge!(opts)
184
186
  end
185
187
 
186
188
  def options
@@ -256,9 +258,9 @@ module Sidekiq
256
258
  opts[:profile] = arg
257
259
  end
258
260
 
259
- o.on "-q", "--queue QUEUE[,WEIGHT]...", "Queues to process with optional weights" do |arg|
260
- queues_and_weights = arg.scan(/([\w\.-]+),?(\d*)/)
261
- parse_queues opts, queues_and_weights
261
+ o.on "-q", "--queue QUEUE[,WEIGHT]", "Queues to process with optional weights" do |arg|
262
+ queue, weight = arg.split(",")
263
+ parse_queue opts, queue, weight
262
264
  end
263
265
 
264
266
  o.on '-r', '--require [PATH|DIR]', "Location of Rails application with workers or file to require" do |arg|
@@ -334,14 +336,14 @@ module Sidekiq
334
336
  end
335
337
 
336
338
  def parse_queues(opts, queues_and_weights)
337
- queues_and_weights.each {|queue_and_weight| parse_queue(opts, *queue_and_weight)}
338
- opts[:strict] = queues_and_weights.all? {|_, weight| weight.to_s.empty? }
339
+ queues_and_weights.each { |queue_and_weight| parse_queue(opts, *queue_and_weight) }
339
340
  end
340
341
 
341
342
  def parse_queue(opts, q, weight=nil)
342
343
  [weight.to_i, 1].max.times do
343
344
  (opts[:queues] ||= []) << q
344
345
  end
346
+ opts[:strict] = false if weight.to_i > 0
345
347
  end
346
348
  end
347
349
  end
@@ -48,6 +48,9 @@ module Sidekiq
48
48
 
49
49
  manager.async.stop(:shutdown => true, :timeout => @options[:timeout])
50
50
  manager.wait(:shutdown)
51
+
52
+ # Requeue everything in case there was a worker who grabbed work while stopped
53
+ Sidekiq::Fetcher.strategy.bulk_requeue([], @options)
51
54
  end
52
55
  end
53
56
 
@@ -162,12 +162,11 @@ module Sidekiq
162
162
  watchdog("Manager#hard_shutdown_in died") do
163
163
  # We've reached the timeout and we still have busy workers.
164
164
  # They must die but their messages shall live on.
165
- logger.info("Still waiting for #{@busy.size} busy workers")
165
+ logger.warn { "Terminating #{@busy.size} busy worker threads" }
166
+ logger.warn { "Work still in progress #{@in_progress.values.inspect}" }
166
167
 
167
168
  requeue
168
169
 
169
- logger.warn { "Terminating #{@busy.size} busy worker threads" }
170
- logger.warn { "Work still in progress #{@in_progress.values.inspect}" }
171
170
  @busy.each do |processor|
172
171
  if processor.alive? && t = @threads.delete(processor.object_id)
173
172
  t.raise Shutdown
@@ -14,7 +14,7 @@ module Sidekiq::Middleware::I18n
14
14
  I18n.locale = msg['locale'] || I18n.default_locale
15
15
  yield
16
16
  ensure
17
- I18n.locale = nil
17
+ I18n.locale = I18n.default_locale
18
18
  end
19
19
  end
20
20
  end
@@ -1,3 +1,3 @@
1
1
  module Sidekiq
2
- VERSION = "2.17.1"
2
+ VERSION = "2.17.2"
3
3
  end
@@ -33,15 +33,44 @@ class TestApi < Sidekiq::Test
33
33
  end
34
34
 
35
35
  describe "reset" do
36
- it 'can reset stats' do
36
+ before do
37
37
  Sidekiq.redis do |conn|
38
38
  conn.set('stat:processed', 5)
39
39
  conn.set('stat:failed', 10)
40
- Sidekiq::Stats.new.reset
40
+ end
41
+ end
42
+
43
+ it 'will reset all stats by default' do
44
+ Sidekiq::Stats.new.reset
45
+ Sidekiq.redis do |conn|
41
46
  assert_equal '0', conn.get('stat:processed')
42
47
  assert_equal '0', conn.get('stat:failed')
43
48
  end
44
49
  end
50
+
51
+ it 'can reset individual stats' do
52
+ Sidekiq::Stats.new.reset('failed')
53
+ Sidekiq.redis do |conn|
54
+ assert_equal '5', conn.get('stat:processed')
55
+ assert_equal '0', conn.get('stat:failed')
56
+ end
57
+ end
58
+
59
+ it 'can accept anything that responds to #to_s' do
60
+ Sidekiq::Stats.new.reset(:failed)
61
+ Sidekiq.redis do |conn|
62
+ assert_equal '5', conn.get('stat:processed')
63
+ assert_equal '0', conn.get('stat:failed')
64
+ end
65
+ end
66
+
67
+ it 'ignores anything other than "failed" or "processed"' do
68
+ Sidekiq::Stats.new.reset((1..10).to_a, ['failed'])
69
+ Sidekiq.redis do |conn|
70
+ assert_equal '5', conn.get('stat:processed')
71
+ assert_equal '0', conn.get('stat:failed')
72
+ end
73
+ end
45
74
  end
46
75
 
47
76
  describe "queues" do
@@ -51,7 +51,7 @@ class TestCli < Sidekiq::Test
51
51
  end
52
52
 
53
53
  it 'sets strictly ordered queues if weights are not present' do
54
- @cli.parse(['sidekiq', '-q', 'foo,bar', '-r', './test/fake_env.rb'])
54
+ @cli.parse(['sidekiq', '-q', 'foo', '-q', 'bar', '-r', './test/fake_env.rb'])
55
55
  assert_equal true, !!Sidekiq.options[:strict]
56
56
  end
57
57
 
@@ -60,23 +60,23 @@ class TestCli < Sidekiq::Test
60
60
  assert_equal false, !!Sidekiq.options[:strict]
61
61
  end
62
62
 
63
+ it 'does not set strictly ordered queues if weights are present with multiple queues' do
64
+ @cli.parse(['sidekiq', '-q', 'foo,3', '-q', 'bar', '-r', './test/fake_env.rb'])
65
+ assert_equal false, !!Sidekiq.options[:strict]
66
+ end
67
+
63
68
  it 'changes timeout' do
64
69
  @cli.parse(['sidekiq', '-t', '30', '-r', './test/fake_env.rb'])
65
70
  assert_equal 30, Sidekiq.options[:timeout]
66
71
  end
67
72
 
68
- it 'handles multiple queues with weights with multiple switches' do
73
+ it 'handles multiple queues with weights' do
69
74
  @cli.parse(['sidekiq', '-q', 'foo,3', '-q', 'bar', '-r', './test/fake_env.rb'])
70
75
  assert_equal %w(foo foo foo bar), Sidekiq.options[:queues]
71
76
  end
72
77
 
73
- it 'handles multiple queues with weights with a single switch' do
74
- @cli.parse(['sidekiq', '-q', 'bar,foo,3', '-r', './test/fake_env.rb'])
75
- assert_equal %w(bar foo foo foo), Sidekiq.options[:queues]
76
- end
77
-
78
78
  it 'handles queues with multi-word names' do
79
- @cli.parse(['sidekiq', '-q', 'queue_one,queue-two', '-r', './test/fake_env.rb'])
79
+ @cli.parse(['sidekiq', '-q', 'queue_one', '-q', 'queue-two', '-r', './test/fake_env.rb'])
80
80
  assert_equal %w(queue_one queue-two), Sidekiq.options[:queues]
81
81
  end
82
82
 
@@ -287,18 +287,20 @@ class TestCli < Sidekiq::Test
287
287
  describe 'Sidekiq::CLI#parse_queues' do
288
288
  describe 'when weight is present' do
289
289
  it 'concatenates queues by factor of weight and sets strict to false' do
290
- opts = {}
291
- @cli.send :parse_queues, opts, [['often', 7]]
292
- assert_equal %w[often] * 7, opts[:queues]
290
+ opts = { strict: true }
291
+ @cli.send :parse_queues, opts, [['often', 7], ['repeatedly', 3]]
292
+ @cli.send :parse_queues, opts, [['once']]
293
+ assert_equal (%w[often] * 7 + %w[repeatedly] * 3 + %w[once]), opts[:queues]
293
294
  assert !opts[:strict]
294
295
  end
295
296
  end
296
297
 
297
298
  describe 'when weight is not present' do
298
299
  it 'returns queues and sets strict' do
299
- opts = {}
300
- @cli.send :parse_queues, opts, [['once']]
301
- assert_equal %w[once], opts[:queues]
300
+ opts = { strict: true }
301
+ @cli.send :parse_queues, opts, [['once'], ['one_time']]
302
+ @cli.send :parse_queues, opts, [['einmal']]
303
+ assert_equal %w[once one_time einmal], opts[:queues]
302
304
  assert opts[:strict]
303
305
  end
304
306
  end
@@ -306,18 +308,20 @@ class TestCli < Sidekiq::Test
306
308
 
307
309
  describe 'Sidekiq::CLI#parse_queue' do
308
310
  describe 'when weight is present' do
309
- it 'concatenates queue to opts[:queues] weight number of times' do
310
- opts = {}
311
+ it 'concatenates queue to opts[:queues] weight number of times and sets strict to false' do
312
+ opts = { strict: true }
311
313
  @cli.send :parse_queue, opts, 'often', 7
312
314
  assert_equal %w[often] * 7, opts[:queues]
315
+ assert !opts[:strict]
313
316
  end
314
317
  end
315
318
 
316
319
  describe 'when weight is not present' do
317
- it 'concatenates queue to opts[:queues] once' do
318
- opts = {}
320
+ it 'concatenates queue to opts[:queues] once and leaves strict true' do
321
+ opts = { strict: true }
319
322
  @cli.send :parse_queue, opts, 'once', nil
320
323
  assert_equal %w[once], opts[:queues]
324
+ assert opts[:strict]
321
325
  end
322
326
  end
323
327
  end
@@ -123,7 +123,7 @@ class TestMiddleware < Sidekiq::Test
123
123
  assert_equal :fr, msg['locale']
124
124
 
125
125
  msg['locale'] = 'jp'
126
- I18n.locale = nil
126
+ I18n.locale = I18n.default_locale
127
127
  assert_equal :en, I18n.locale
128
128
  mw = Sidekiq::Middleware::I18n::Server.new
129
129
  mw.call(nil, msg, nil) do
@@ -131,5 +131,19 @@ class TestMiddleware < Sidekiq::Test
131
131
  end
132
132
  assert_equal :en, I18n.locale
133
133
  end
134
+
135
+ it 'supports I18n.enforce_available_locales = true' do
136
+ I18n.enforce_available_locales = true
137
+ I18n.available_locales = [:en, :jp]
138
+
139
+ msg = { 'locale' => 'jp' }
140
+ mw = Sidekiq::Middleware::I18n::Server.new
141
+ mw.call(nil, msg, nil) do
142
+ assert_equal :jp, I18n.locale
143
+ end
144
+
145
+ I18n.enforce_available_locales = nil
146
+ I18n.available_locales = nil
147
+ end
134
148
  end
135
149
  end
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: 2.17.1
4
+ version: 2.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-15 00:00:00.000000000 Z
11
+ date: 2014-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -352,7 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
352
352
  version: '0'
353
353
  requirements: []
354
354
  rubyforge_project:
355
- rubygems_version: 2.1.9
355
+ rubygems_version: 2.0.14
356
356
  signing_key:
357
357
  specification_version: 4
358
358
  summary: Simple, efficient background processing for Ruby