sidekiq 5.0.0.beta1 → 5.0.0.beta2

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.

Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +6 -0
  3. data/Pro-Changes.md +3 -2
  4. data/bin/sidekiqload +11 -11
  5. data/lib/sidekiq/api.rb +15 -8
  6. data/lib/sidekiq/job_retry.rb +15 -12
  7. data/lib/sidekiq/processor.rb +3 -2
  8. data/lib/sidekiq/version.rb +1 -1
  9. data/lib/sidekiq/web/application.rb +1 -1
  10. data/lib/sidekiq/web/helpers.rb +2 -1
  11. data/sidekiq.gemspec +2 -2
  12. data/web/views/retry.erb +1 -1
  13. metadata +3 -67
  14. data/test/config.yml +0 -9
  15. data/test/env_based_config.yml +0 -11
  16. data/test/fake_env.rb +0 -1
  17. data/test/fixtures/en.yml +0 -2
  18. data/test/helper.rb +0 -98
  19. data/test/test_actors.rb +0 -138
  20. data/test/test_api.rb +0 -529
  21. data/test/test_cli.rb +0 -418
  22. data/test/test_client.rb +0 -266
  23. data/test/test_exception_handler.rb +0 -56
  24. data/test/test_extensions.rb +0 -115
  25. data/test/test_fetch.rb +0 -50
  26. data/test/test_launcher.rb +0 -92
  27. data/test/test_logging.rb +0 -35
  28. data/test/test_manager.rb +0 -50
  29. data/test/test_middleware.rb +0 -158
  30. data/test/test_processor.rb +0 -266
  31. data/test/test_rails.rb +0 -22
  32. data/test/test_redis_connection.rb +0 -132
  33. data/test/test_retry.rb +0 -335
  34. data/test/test_retry_exhausted.rb +0 -149
  35. data/test/test_scheduled.rb +0 -115
  36. data/test/test_scheduling.rb +0 -58
  37. data/test/test_sidekiq.rb +0 -107
  38. data/test/test_testing.rb +0 -135
  39. data/test/test_testing_fake.rb +0 -352
  40. data/test/test_testing_inline.rb +0 -93
  41. data/test/test_util.rb +0 -13
  42. data/test/test_web.rb +0 -638
  43. data/test/test_web_auth.rb +0 -54
  44. data/test/test_web_helpers.rb +0 -54
  45. data/test/test_web_sessions.rb +0 -67
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95da469a298b66ee3541eebedff02fa7e78bafa5
4
- data.tar.gz: 527583034d9da07b968edaf9e5494d86fd953a3c
3
+ metadata.gz: 30b76f139772bc64e9e195dea6f3902457a3c57f
4
+ data.tar.gz: 494f165c4db4cc2a157eddc96edc6f4482e1e24e
5
5
  SHA512:
6
- metadata.gz: 69243c242c3a520711d6afd75a986287b0a064751565d11ee136de74e74261c42646f2f2d0dd6c590213f58bb2ad40bd5c0aca7478a614cc6811b4aa27dfaa7a
7
- data.tar.gz: 21159d28edee7f271deec190f7ce013d91cdac0d91e69c995643c26d0c4df97ce7425131f3e749da0e5880a374569fb1361cdd1c5ec598150b2d29a49f8fbbcf
6
+ metadata.gz: 372324120d0b6790f2dce79e46f75cfacb1889138ac355365480fb3bde66d315739d63308e3ed51dd95a1cf0a9f0a89d663374d22cbcade15b2cfc0155d23077
7
+ data.tar.gz: '0905217ddba496c76b7afbfa68765eb6e256924264ec5c5f3d1c76b29d2ff98d87300f6b266486effd00b1373b2fad1f2e1824b5b7242f938cd2cd8cd78c6656'
data/Changes.md CHANGED
@@ -17,6 +17,12 @@ Sidekiq::Middleware::Server::Logging -> Sidekiq::JobLogging
17
17
  - Rails 3.2 and Ruby 2.0 and 2.1 are no longer supported.
18
18
  - Please see the [5.0 Upgrade notes](5.0-Upgrade.md) for more detail.
19
19
 
20
+ master
21
+ -----------
22
+
23
+ - Fix error class name display on retry page [#3348]
24
+ - More robust latency calculation [#3340]
25
+
20
26
  4.2.9
21
27
  -----------
22
28
 
@@ -3,10 +3,11 @@ Sidekiq Pro Changelog
3
3
 
4
4
  Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
5
5
 
6
- HEAD
6
+ 3.4.3
7
7
  ---------
8
8
 
9
- - Update reliable scheduler to enqueue up to 100 jobs per call, minimizing Redis latency [#3332]
9
+ - Limit reliable scheduler to enqueue up to 100 jobs per call, minimizing Redis latency [#3332]
10
+ - Fix bug in super\_fetch logic for queues with `_` in the name [#3339]
10
11
 
11
12
  3.4.2
12
13
  ---------
@@ -14,7 +14,7 @@ include Sidekiq::Util
14
14
 
15
15
  Sidekiq.configure_server do |config|
16
16
  #config.options[:concurrency] = 1
17
- config.redis = { driver: :hiredis, db: 13, port: 6380 }
17
+ config.redis = { db: 13 }
18
18
  config.options[:queues] << 'default'
19
19
  config.logger.level = Logger::ERROR
20
20
  config.average_scheduled_poll_interval = 2
@@ -36,14 +36,14 @@ end
36
36
  # brew tap shopify/shopify
37
37
  # brew install toxiproxy
38
38
  # gem install toxiproxy
39
- require 'toxiproxy'
39
+ #require 'toxiproxy'
40
40
  # simulate a non-localhost network for realer-world conditions.
41
41
  # adding 1ms of network latency has an ENORMOUS impact on benchmarks
42
- Toxiproxy.populate([{
43
- "name": "redis",
44
- "listen": "127.0.0.1:6380",
45
- "upstream": "127.0.0.1:6379"
46
- }])
42
+ #Toxiproxy.populate([{
43
+ #"name": "redis",
44
+ #"listen": "127.0.0.1:6380",
45
+ #"upstream": "127.0.0.1:6379"
46
+ #}])
47
47
 
48
48
  self_read, self_write = IO.pipe
49
49
  %w(INT TERM TSTP TTIN).each do |sig|
@@ -103,7 +103,7 @@ Sidekiq.logger.error "Created #{count*iter} jobs"
103
103
  Monitoring = Thread.new do
104
104
  watchdog("monitor thread") do
105
105
  while true
106
- sleep 2
106
+ sleep 1
107
107
  qsize, retries = Sidekiq.redis do |conn|
108
108
  conn.pipelined do
109
109
  conn.llen "queue:default"
@@ -125,8 +125,8 @@ begin
125
125
  #RubyProf::exclude_threads = [ Monitoring ]
126
126
  #RubyProf.start
127
127
  fire_event(:startup)
128
- Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
129
- Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
128
+ #Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
129
+ #Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
130
130
  launcher = Sidekiq::Launcher.new(Sidekiq.options)
131
131
  launcher.run
132
132
 
@@ -134,7 +134,7 @@ begin
134
134
  signal = readable_io.first[0].gets.strip
135
135
  handle_signal(launcher, signal)
136
136
  end
137
- end
137
+ #end
138
138
  rescue SystemExit => e
139
139
  #Sidekiq.logger.error("Profiling...")
140
140
  #result = RubyProf.stop
@@ -75,7 +75,10 @@ module Sidekiq
75
75
  enqueued = pipe2_res[s..-1].map(&:to_i).inject(0, &:+)
76
76
 
77
77
  default_queue_latency = if (entry = pipe1_res[6].first)
78
- Time.now.to_f - Sidekiq.load_json(entry)['enqueued_at'.freeze]
78
+ job = Sidekiq.load_json(entry)
79
+ now = Time.now.to_f
80
+ thence = job['enqueued_at'.freeze] || now
81
+ now - thence
79
82
  else
80
83
  0
81
84
  end
@@ -225,7 +228,10 @@ module Sidekiq
225
228
  conn.lrange(@rname, -1, -1)
226
229
  end.first
227
230
  return 0 unless entry
228
- Time.now.to_f - Sidekiq.load_json(entry)['enqueued_at']
231
+ job = Sidekiq.load_json(entry)
232
+ now = Time.now.to_f
233
+ thence = job['enqueued_at'] || now
234
+ now - thence
229
235
  end
230
236
 
231
237
  def each
@@ -355,7 +361,8 @@ module Sidekiq
355
361
  end
356
362
 
357
363
  def latency
358
- Time.now.to_f - (self['enqueued_at'] || self['created_at'] || 0)
364
+ now = Time.now.to_f
365
+ now - (@item['enqueued_at'] || @item['created_at'] || now)
359
366
  end
360
367
 
361
368
  ##
@@ -592,13 +599,13 @@ module Sidekiq
592
599
  # Allows enumeration of scheduled jobs within Sidekiq.
593
600
  # Based on this, you can search/filter for jobs. Here's an
594
601
  # example where I'm selecting all jobs of a certain type
595
- # and deleting them from the retry queue.
602
+ # and deleting them from the schedule queue.
596
603
  #
597
604
  # r = Sidekiq::ScheduledSet.new
598
- # r.select do |retri|
599
- # retri.klass == 'Sidekiq::Extensions::DelayedClass' &&
600
- # retri.args[0] == 'User' &&
601
- # retri.args[1] == 'setup_new_subscriber'
605
+ # r.select do |scheduled|
606
+ # scheduled.klass == 'Sidekiq::Extensions::DelayedClass' &&
607
+ # scheduled.args[0] == 'User' &&
608
+ # scheduled.args[1] == 'setup_new_subscriber'
602
609
  # end.map(&:delete)
603
610
  class ScheduledSet < JobSet
604
611
  def initialize
@@ -70,30 +70,36 @@ module Sidekiq
70
70
  # require the worker to be instantiated.
71
71
  def global(msg, queue)
72
72
  yield
73
- rescue Skip
74
- raise
75
- rescue Sidekiq::Shutdown
73
+ rescue Skip => ex
74
+ raise ex
75
+ rescue Sidekiq::Shutdown => ey
76
76
  # ignore, will be pushed back onto queue during hard_shutdown
77
- raise
77
+ raise ey
78
78
  rescue Exception => e
79
79
  # ignore, will be pushed back onto queue during hard_shutdown
80
80
  raise Sidekiq::Shutdown if exception_caused_by_shutdown?(e)
81
81
 
82
82
  raise e unless msg['retry']
83
83
  attempt_retry(nil, msg, queue, e)
84
+ raise e
84
85
  end
85
86
 
86
87
 
87
88
  # The local retry support means that any errors that occur within
88
89
  # this block can be associated with the given worker instance.
89
90
  # This is required to support the `sidekiq_retries_exhausted` block.
91
+ #
92
+ # Note that any exception from the block is wrapped in the Skip
93
+ # exception so the global block does not reprocess the error. The
94
+ # Skip exception is unwrapped within Sidekiq::Processor#process before
95
+ # calling the handle_exception handlers.
90
96
  def local(worker, msg, queue)
91
97
  yield
92
- rescue Skip
93
- raise
94
- rescue Sidekiq::Shutdown
98
+ rescue Skip => ex
99
+ raise ex
100
+ rescue Sidekiq::Shutdown => ey
95
101
  # ignore, will be pushed back onto queue during hard_shutdown
96
- raise
102
+ raise ey
97
103
  rescue Exception => e
98
104
  # ignore, will be pushed back onto queue during hard_shutdown
99
105
  raise Sidekiq::Shutdown if exception_caused_by_shutdown?(e)
@@ -161,8 +167,6 @@ module Sidekiq
161
167
  # Goodbye dear message, you (re)tried your best I'm sure.
162
168
  retries_exhausted(worker, msg, exception)
163
169
  end
164
-
165
- raise exception
166
170
  end
167
171
 
168
172
  def retries_exhausted(worker, msg, exception)
@@ -217,8 +221,7 @@ module Sidekiq
217
221
  end
218
222
 
219
223
  def exception_caused_by_shutdown?(e, checked_causes = [])
220
- # In Ruby 2.1.0 only, check if exception is a result of shutdown.
221
- return false unless defined?(e.cause)
224
+ return false unless e.cause
222
225
 
223
226
  # Handle circular causes
224
227
  checked_causes << e.object_id
@@ -179,8 +179,9 @@ module Sidekiq
179
179
  # we didn't properly finish it.
180
180
  ack = false
181
181
  rescue Exception => ex
182
- handle_exception(ex, { :context => "Job raised exception", :job => job_hash, :jobstr => jobstr })
183
- raise
182
+ e = ex.is_a?(::Sidekiq::JobRetry::Skip) && ex.cause ? ex.cause : ex
183
+ handle_exception(e, { :context => "Job raised exception", :job => job_hash, :jobstr => jobstr })
184
+ raise e
184
185
  ensure
185
186
  work.acknowledge if ack
186
187
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Sidekiq
3
- VERSION = "5.0.0.beta1"
3
+ VERSION = "5.0.0.beta2"
4
4
  end
@@ -281,7 +281,7 @@ module Sidekiq
281
281
  when :json
282
282
  { "Content-Type" => "application/json", "Cache-Control" => "no-cache" }
283
283
  when String
284
- { "Content-Type" => action.type, "Cache-Control" => "no-cache" }
284
+ { "Content-Type" => (action.type || "text/html"), "Cache-Control" => "no-cache" }
285
285
  else
286
286
  { "Content-Type" => "text/html", "Cache-Control" => "no-cache" }
287
287
  end
@@ -2,6 +2,7 @@
2
2
  require 'uri'
3
3
  require 'set'
4
4
  require 'yaml'
5
+ require 'cgi'
5
6
 
6
7
  module Sidekiq
7
8
  # This is not a public API
@@ -161,7 +162,7 @@ module Sidekiq
161
162
  def qparams(options)
162
163
  options = options.stringify_keys
163
164
  params.merge(options).map do |key, value|
164
- SAFE_QPARAMS.include?(key) ? "#{key}=#{value}" : next
165
+ SAFE_QPARAMS.include?(key) ? "#{key}=#{CGI.escape(value.to_s)}" : next
165
166
  end.compact.join("&")
166
167
  end
167
168
 
@@ -10,8 +10,8 @@ Gem::Specification.new do |gem|
10
10
  gem.license = "LGPL-3.0"
11
11
 
12
12
  gem.executables = ['sidekiq', 'sidekiqctl']
13
- gem.files = `git ls-files | grep -Ev '^(myapp|examples)'`.split("\n")
14
- gem.test_files = `git ls-files -- test/*`.split("\n")
13
+ gem.files = `git ls-files | grep -Ev '^(test|myapp|examples)'`.split("\n")
14
+ gem.test_files = []
15
15
  gem.name = "sidekiq"
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = Sidekiq::VERSION
@@ -7,7 +7,7 @@
7
7
  <tr>
8
8
  <th><%= t('ErrorClass') %></th>
9
9
  <td>
10
- <code><%= h @retry.display_class %></code>
10
+ <code><%= h @retry['error_class'] %></code>
11
11
  </td>
12
12
  </tr>
13
13
  <tr>
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: 5.0.0.beta1
4
+ version: 5.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-31 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -286,38 +286,6 @@ files:
286
286
  - lib/sidekiq/web/router.rb
287
287
  - lib/sidekiq/worker.rb
288
288
  - sidekiq.gemspec
289
- - test/config.yml
290
- - test/env_based_config.yml
291
- - test/fake_env.rb
292
- - test/fixtures/en.yml
293
- - test/helper.rb
294
- - test/test_actors.rb
295
- - test/test_api.rb
296
- - test/test_cli.rb
297
- - test/test_client.rb
298
- - test/test_exception_handler.rb
299
- - test/test_extensions.rb
300
- - test/test_fetch.rb
301
- - test/test_launcher.rb
302
- - test/test_logging.rb
303
- - test/test_manager.rb
304
- - test/test_middleware.rb
305
- - test/test_processor.rb
306
- - test/test_rails.rb
307
- - test/test_redis_connection.rb
308
- - test/test_retry.rb
309
- - test/test_retry_exhausted.rb
310
- - test/test_scheduled.rb
311
- - test/test_scheduling.rb
312
- - test/test_sidekiq.rb
313
- - test/test_testing.rb
314
- - test/test_testing_fake.rb
315
- - test/test_testing_inline.rb
316
- - test/test_util.rb
317
- - test/test_web.rb
318
- - test/test_web_auth.rb
319
- - test/test_web_helpers.rb
320
- - test/test_web_sessions.rb
321
289
  - web/assets/images/favicon.ico
322
290
  - web/assets/images/logo.png
323
291
  - web/assets/images/status.png
@@ -389,36 +357,4 @@ rubygems_version: 2.5.2
389
357
  signing_key:
390
358
  specification_version: 4
391
359
  summary: Simple, efficient background processing for Ruby
392
- test_files:
393
- - test/config.yml
394
- - test/env_based_config.yml
395
- - test/fake_env.rb
396
- - test/fixtures/en.yml
397
- - test/helper.rb
398
- - test/test_actors.rb
399
- - test/test_api.rb
400
- - test/test_cli.rb
401
- - test/test_client.rb
402
- - test/test_exception_handler.rb
403
- - test/test_extensions.rb
404
- - test/test_fetch.rb
405
- - test/test_launcher.rb
406
- - test/test_logging.rb
407
- - test/test_manager.rb
408
- - test/test_middleware.rb
409
- - test/test_processor.rb
410
- - test/test_rails.rb
411
- - test/test_redis_connection.rb
412
- - test/test_retry.rb
413
- - test/test_retry_exhausted.rb
414
- - test/test_scheduled.rb
415
- - test/test_scheduling.rb
416
- - test/test_sidekiq.rb
417
- - test/test_testing.rb
418
- - test/test_testing_fake.rb
419
- - test/test_testing_inline.rb
420
- - test/test_util.rb
421
- - test/test_web.rb
422
- - test/test_web_auth.rb
423
- - test/test_web_helpers.rb
424
- - test/test_web_sessions.rb
360
+ test_files: []
@@ -1,9 +0,0 @@
1
- ---
2
- :verbose: false
3
- :require: ./test/fake_env.rb
4
- :pidfile: /tmp/sidekiq-config-test.pid
5
- :logfile: /tmp/sidekiq.log
6
- :concurrency: 50
7
- :queues:
8
- - [<%="very_"%>often, 2]
9
- - [seldom, 1]
@@ -1,11 +0,0 @@
1
- ---
2
- :pidfile: /tmp/sidekiq-config-test.pid
3
- :concurrency: 50
4
- staging:
5
- :verbose: false
6
- :require: ./test/fake_env.rb
7
- :logfile: /tmp/sidekiq.log
8
- :concurrency: 5
9
- :queues:
10
- - [<%="very_"%>often, 2]
11
- - [seldom, 1]
@@ -1 +0,0 @@
1
- # frozen_string_literal: true
@@ -1,2 +0,0 @@
1
- en:
2
- translated_text: 'Changed text from add locals'
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
- $TESTING = true
3
- # disable minitest/parallel threads
4
- ENV["N"] = "0"
5
-
6
- require 'capybara'
7
- require 'capybara/dsl'
8
- require 'capybara/poltergeist'
9
-
10
- Capybara.register_driver :poltergeist do |app|
11
- Capybara::Poltergeist::Driver.new(app,
12
- debug: false, js_errors: false, timeout: 180
13
- )
14
- end
15
-
16
- def percy_enabled?
17
- !(ENV['PERCY_ENABLE'] == '0')
18
- end
19
- require 'percy/capybara' if percy_enabled?
20
-
21
- if ENV["COVERAGE"]
22
- require 'simplecov'
23
- SimpleCov.start do
24
- add_filter "/test/"
25
- add_filter "/myapp/"
26
- end
27
- end
28
- ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'test'
29
-
30
- trap 'TSTP' do
31
- threads = Thread.list
32
-
33
- puts
34
- puts "=" * 80
35
- puts "Received TSTP signal; printing all #{threads.count} thread backtraces."
36
-
37
- threads.each do |thr|
38
- description = thr == Thread.main ? "Main thread" : thr.inspect
39
- puts
40
- puts "#{description} backtrace: "
41
- puts thr.backtrace.join("\n")
42
- end
43
-
44
- puts "=" * 80
45
- end
46
-
47
- begin
48
- require 'pry-byebug'
49
- rescue LoadError
50
- end
51
-
52
- require 'minitest/autorun'
53
-
54
- require 'sidekiq'
55
- require 'sidekiq/util'
56
- Sidekiq.logger.level = Logger::ERROR
57
-
58
- Sidekiq::Test = Minitest::Test
59
-
60
- require 'sidekiq/redis_connection'
61
- REDIS_URL = ENV['REDIS_URL'] || 'redis://localhost/15'
62
- REDIS = Sidekiq::RedisConnection.create(:url => REDIS_URL, :namespace => 'testy')
63
-
64
- Sidekiq.configure_client do |config|
65
- config.redis = { :url => REDIS_URL, :namespace => 'testy' }
66
- end
67
-
68
- def capture_logging(lvl=Logger::INFO)
69
- old = Sidekiq.logger
70
- begin
71
- out = StringIO.new
72
- logger = Logger.new(out)
73
- logger.level = lvl
74
- Sidekiq.logger = logger
75
- yield
76
- out.string
77
- ensure
78
- Sidekiq.logger = old
79
- end
80
- end
81
-
82
- def with_logging(lvl=Logger::DEBUG)
83
- old = Sidekiq.logger.level
84
- begin
85
- Sidekiq.logger.level = lvl
86
- yield
87
- ensure
88
- Sidekiq.logger.level = old
89
- end
90
- end
91
-
92
- if percy_enabled?
93
- # Initialize and finalize Percy.io
94
- Percy::Capybara.initialize_build
95
- MiniTest.after_run {
96
- Percy::Capybara.finalize_build
97
- }
98
- end