sidekiq 4.2.10 → 5.2.7

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 (75) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +61 -0
  3. data/.github/issue_template.md +3 -1
  4. data/.gitignore +3 -0
  5. data/.travis.yml +6 -13
  6. data/5.0-Upgrade.md +56 -0
  7. data/COMM-LICENSE +12 -10
  8. data/Changes.md +158 -1
  9. data/Ent-Changes.md +67 -2
  10. data/Gemfile +14 -20
  11. data/LICENSE +1 -1
  12. data/Pro-4.0-Upgrade.md +35 -0
  13. data/Pro-Changes.md +133 -2
  14. data/README.md +8 -6
  15. data/Rakefile +2 -5
  16. data/bin/sidekiqctl +13 -92
  17. data/bin/sidekiqload +5 -10
  18. data/lib/generators/sidekiq/templates/worker_spec.rb.erb +1 -1
  19. data/lib/sidekiq.rb +27 -27
  20. data/lib/sidekiq/api.rb +145 -57
  21. data/lib/sidekiq/cli.rb +120 -81
  22. data/lib/sidekiq/client.rb +25 -18
  23. data/lib/sidekiq/core_ext.rb +1 -119
  24. data/lib/sidekiq/ctl.rb +221 -0
  25. data/lib/sidekiq/delay.rb +42 -0
  26. data/lib/sidekiq/exception_handler.rb +2 -4
  27. data/lib/sidekiq/extensions/generic_proxy.rb +7 -1
  28. data/lib/sidekiq/fetch.rb +1 -1
  29. data/lib/sidekiq/job_logger.rb +25 -0
  30. data/lib/sidekiq/job_retry.rb +262 -0
  31. data/lib/sidekiq/launcher.rb +19 -19
  32. data/lib/sidekiq/logging.rb +18 -2
  33. data/lib/sidekiq/manager.rb +5 -6
  34. data/lib/sidekiq/middleware/server/active_record.rb +10 -0
  35. data/lib/sidekiq/processor.rb +126 -48
  36. data/lib/sidekiq/rails.rb +8 -73
  37. data/lib/sidekiq/redis_connection.rb +43 -5
  38. data/lib/sidekiq/scheduled.rb +35 -8
  39. data/lib/sidekiq/testing.rb +16 -7
  40. data/lib/sidekiq/util.rb +5 -2
  41. data/lib/sidekiq/version.rb +1 -1
  42. data/lib/sidekiq/web.rb +4 -4
  43. data/lib/sidekiq/web/action.rb +2 -6
  44. data/lib/sidekiq/web/application.rb +33 -16
  45. data/lib/sidekiq/web/helpers.rb +69 -22
  46. data/lib/sidekiq/web/router.rb +10 -10
  47. data/lib/sidekiq/worker.rb +118 -19
  48. data/sidekiq.gemspec +6 -17
  49. data/web/assets/javascripts/application.js +0 -0
  50. data/web/assets/javascripts/dashboard.js +32 -17
  51. data/web/assets/stylesheets/application-rtl.css +246 -0
  52. data/web/assets/stylesheets/application.css +371 -6
  53. data/web/assets/stylesheets/bootstrap-rtl.min.css +9 -0
  54. data/web/assets/stylesheets/bootstrap.css +2 -2
  55. data/web/locales/ar.yml +81 -0
  56. data/web/locales/en.yml +2 -0
  57. data/web/locales/es.yml +4 -3
  58. data/web/locales/fa.yml +1 -0
  59. data/web/locales/he.yml +79 -0
  60. data/web/locales/ja.yml +5 -3
  61. data/web/locales/ur.yml +80 -0
  62. data/web/views/_footer.erb +5 -2
  63. data/web/views/_nav.erb +4 -18
  64. data/web/views/_paging.erb +1 -1
  65. data/web/views/busy.erb +9 -5
  66. data/web/views/dashboard.erb +1 -1
  67. data/web/views/layout.erb +11 -2
  68. data/web/views/morgue.erb +4 -4
  69. data/web/views/queue.erb +8 -7
  70. data/web/views/queues.erb +2 -0
  71. data/web/views/retries.erb +9 -5
  72. data/web/views/scheduled.erb +2 -2
  73. metadata +31 -160
  74. data/lib/sidekiq/middleware/server/logging.rb +0 -31
  75. data/lib/sidekiq/middleware/server/retry_jobs.rb +0 -205
data/Gemfile CHANGED
@@ -1,29 +1,23 @@
1
1
  source 'https://rubygems.org'
2
+
2
3
  gemspec
3
4
 
4
- gem 'rails', '>= 5.0.1'
5
- gem "hiredis"
6
- gem 'simplecov'
7
- gem 'minitest'
8
- #gem 'minitest-utils'
9
- gem 'toxiproxy'
5
+ gem 'rake'
6
+ gem 'redis-namespace'
7
+ gem 'rails', '~> 5.2'
8
+ gem 'sqlite3', '~> 1.3.6', platforms: :ruby
9
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
10
10
 
11
- platforms :rbx do
12
- gem 'rubysl', '~> 2.0' # if using anything in the ruby standard library
13
- gem 'psych' # if using yaml
14
- gem 'rubinius-developer_tools' # if using any of coverage, debugger, profiler
11
+ group :test do
12
+ gem 'minitest'
13
+ gem 'simplecov'
15
14
  end
16
15
 
17
- platforms :ruby do
18
- gem 'sqlite3'
16
+ group :development, :test do
17
+ gem 'pry-byebug', platforms: :mri
19
18
  end
20
19
 
21
- platforms :mri do
22
- gem 'pry-byebug'
23
- gem 'ruby-prof'
20
+ group :load_test do
21
+ gem 'hiredis'
22
+ gem 'toxiproxy'
24
23
  end
25
-
26
- #platforms :jruby do
27
- #gem 'jruby-openssl'
28
- #gem 'activerecord-jdbcsqlite3-adapter'
29
- #end
data/LICENSE CHANGED
@@ -5,5 +5,5 @@ the LGPLv3 license. Please see <http://www.gnu.org/licenses/lgpl-3.0.html>
5
5
  for license text.
6
6
 
7
7
  Sidekiq Pro has a commercial-friendly license allowing private forks
8
- and modifications of Sidekiq. Please see http://sidekiq.org/pro/ for
8
+ and modifications of Sidekiq. Please see https://sidekiq.org/products/pro.html for
9
9
  more detail. You can find the commercial license terms in COMM-LICENSE.
@@ -0,0 +1,35 @@
1
+ # Welcome to Sidekiq Pro 4.0!
2
+
3
+ Sidekiq Pro 4.0 is designed to work with Sidekiq 5.0.
4
+
5
+ ## What's New
6
+
7
+ * Batches now "die" if any of their jobs die. You can enumerate the set
8
+ of dead batches and their associated dead jobs. The success callback
9
+ for a dead batch will never fire unless these jobs are fixed.
10
+ ```ruby
11
+ Sidekiq::Batch::DeadSet.new.each do |status|
12
+ status.dead? # => true
13
+ status.dead_jobs # => [...]
14
+ end
15
+ ```
16
+ This API allows you to enumerate the batches which need help.
17
+ If you fix the issue and the dead jobs succeed, the batch will succeed.
18
+ * The older `reliable_fetch` and `timed_fetch` algorithms have been
19
+ removed. Only super\_fetch is available in 4.0.
20
+ * The statsd middleware has been tweaked to remove support for legacy,
21
+ pre-3.6.0 configuration and add relevant tags.
22
+ * Requires Sidekiq 5.0.5+.
23
+
24
+ ## Upgrade
25
+
26
+ * Upgrade to the latest Sidekiq Pro 3.x.
27
+ ```ruby
28
+ gem 'sidekiq-pro', '< 4'
29
+ ```
30
+ * Fix any deprecation warnings you see.
31
+ * Upgrade to 4.x.
32
+ ```ruby
33
+ gem 'sidekiq-pro', '< 5'
34
+ ```
35
+
@@ -1,11 +1,142 @@
1
- Sidekiq Pro Changelog
2
- =======================
1
+ # Sidekiq Pro Changelog
2
+
3
+ [Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
3
4
 
4
5
  Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
5
6
 
6
7
  HEAD
7
8
  ---------
8
9
 
10
+ - Add ES translations, see issues [#3949](https://github.com/mperham/sidekiq/issues/3949) and [#3951](https://github.com/mperham/sidekiq/issues/3951) to add your own language.
11
+
12
+ 4.0.5
13
+ ---------
14
+
15
+ - Increase super\_fetch retriever thread count from 1 to 2 to make it
16
+ less sensitive to Redis latency.
17
+ - Better handling of invalid job JSON by reliable scheduler [#4053]
18
+ - Added ZH, PT, JA and RU translations.
19
+
20
+ 4.0.4
21
+ ---------
22
+
23
+ - Update Sidekiq::Client patches to work with new Module#prepend
24
+ mechanism in Sidekiq 5.2.0. [#3930]
25
+
26
+ 4.0.3
27
+ ---------
28
+
29
+ - Add at\_exit handler to push any saved jobs in `reliable_push` when exiting. [#3823]
30
+ - Implement batch death callback. This is fired the first time a job within a batch dies. [#3841]
31
+ ```ruby
32
+ batch = Sidekiq::Batch.new
33
+ batch.on(:death, ...)
34
+ ```
35
+
36
+ 4.0.2
37
+ ---------
38
+
39
+ - Remove super\_fetch edge case leading to an unnecessary `sleep(1)`
40
+ call and resulting latency [#3790]
41
+ - Fix possible bad statsd metric call on super\_fetch startup
42
+ - Remove superfluous `freeze` calls on Strings [#3759]
43
+
44
+ 4.0.1
45
+ ---------
46
+
47
+ - Fix incompatibility with the statsd-ruby gem [#3740]
48
+ - Add tags to Statsd metrics when using Datadog [#3744]
49
+
50
+ 4.0.0
51
+ ---------
52
+
53
+ - See the [Sidekiq Pro 4.0](Pro-4.0-Upgrade.md) release notes.
54
+
55
+
56
+ 3.7.1
57
+ ---------
58
+
59
+ - Deprecate timed\_fetch. Switch to super\_fetch:
60
+ ```ruby
61
+ config.super_fetch!
62
+ ```
63
+
64
+
65
+ 3.7.0
66
+ ---------
67
+
68
+ - Refactor batch job success/failure to gracefully handle several edge
69
+ cases with regard to Sidekiq::Shutdown. This should greatly reduce
70
+ the chances of seeing the long-standing "negative pending count" problem. [#3710]
71
+
72
+
73
+ 3.6.1
74
+ ---------
75
+
76
+ - Add support for Datadog::Statsd, it is the recommended Statsd client. [#3699]
77
+ ```ruby
78
+ Sidekiq::Pro.dogstatsd = ->{ Datadog::Statsd.new("metrics.example.com", 8125) }
79
+ ```
80
+ - Size the statsd connection pool based on Sidekiq's concurrency [#3700]
81
+
82
+
83
+ 3.6.0
84
+ ---------
85
+
86
+ This release overhauls the Statsd metrics support and adds more
87
+ metrics for tracking Pro feature usage. In your initializer:
88
+ ```ruby
89
+ Sidekiq::Pro.statsd = ->{ ::Statsd.new("127.0.0.1", 8125) }
90
+ ```
91
+ Sidekiq Pro will emit more metrics to Statsd:
92
+ ```
93
+ jobs.expired - when a job is expired
94
+ jobs.recovered.push - when a job is recovered by reliable_push after network outage
95
+ jobs.recovered.fetch - when a job is recovered by super_fetch after process crash
96
+ batch.created - when a batch is created
97
+ batch.complete - when a batch is completed
98
+ batch.success - when a batch is successful
99
+ ```
100
+ Sidekiq Pro's existing Statsd middleware has been rewritten to leverage the new API.
101
+ Everything should be backwards compatible with one deprecation notice.
102
+
103
+
104
+ 3.5.4
105
+ ---------
106
+
107
+ - Fix case in SuperFetch where Redis downtime can lead to processor thread death [#3684]
108
+ - Fix case where TimedFetch might not recover some pending jobs
109
+ - Fix edge case in Batch::Status#poll leading to premature completion [#3640]
110
+ - Adjust scan API to check 100 elements at a time, to minimize network round trips
111
+ when scanning large sets.
112
+
113
+ 3.5.3
114
+ ---------
115
+
116
+ - Restore error check for super\_fetch's job ack [#3601]
117
+ - Trim error messages saved in Batch's failure hash, preventing huge
118
+ messages from bloating Redis. [#3570]
119
+
120
+ 3.5.2
121
+ ---------
122
+
123
+ - Fix `Status#completed?` when run against a Batch that had succeeded
124
+ and was deleted. [#3519]
125
+
126
+ 3.5.1
127
+ ---------
128
+
129
+ - Work with Sidekiq 5.0.2+
130
+ - Improve performance of super\_fetch with weighted queues [#3489]
131
+
132
+ 3.5.0
133
+ ---------
134
+
135
+ - Add queue pause/unpause endpoints for scripting via curl [#3445]
136
+ - Change how super\_fetch names private queues to avoid hostname/queue clashes. [#3443]
137
+ - Re-implement `Sidekiq::Queue#delete_job` to avoid O(n) runtime [#3408]
138
+ - Batch page displays Pending JIDs if less than 10 [#3130]
139
+ - Batch page has a Search button to find associated Retries [#3130]
9
140
  - Make Batch UI progress bar more friendly to the colorblind [#3387]
10
141
 
11
142
  3.4.5
data/README.md CHANGED
@@ -3,7 +3,7 @@ Sidekiq
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/sidekiq.svg)](https://rubygems.org/gems/sidekiq)
5
5
  [![Code Climate](https://codeclimate.com/github/mperham/sidekiq.svg)](https://codeclimate.com/github/mperham/sidekiq)
6
- [![Build Status](https://travis-ci.org/mperham/sidekiq.svg)](https://travis-ci.org/mperham/sidekiq)
6
+ [![Build Status](https://circleci.com/gh/mperham/sidekiq/tree/master.svg?style=svg)](https://circleci.com/gh/mperham/sidekiq/tree/master)
7
7
  [![Gitter Chat](https://badges.gitter.im/mperham/sidekiq.svg)](https://gitter.im/mperham/sidekiq)
8
8
 
9
9
 
@@ -28,13 +28,14 @@ Sidekiq 3.5.1 | 22ms | 1257 MB | 125 sec | 800 jobs/sec
28
28
  Resque 1.25.2 | - | - | 420 sec | 240 jobs/sec
29
29
  DelayedJob 4.1.1 | - | - | 465 sec | 215 jobs/sec
30
30
 
31
+ <small>This benchmark can be found in `bin/sidekiqload`.</small>
31
32
 
32
33
  Requirements
33
34
  -----------------
34
35
 
35
- Sidekiq supports CRuby 2.0+ and JRuby 9k.
36
+ Sidekiq supports CRuby 2.2.2+ and JRuby 9k.
36
37
 
37
- All Rails releases >= 3.2 are officially supported.
38
+ All Rails releases >= 4.0 are officially supported.
38
39
 
39
40
  Redis 2.8 or greater is required. 3.0.3+ is recommended for large
40
41
  installations with thousands of worker threads.
@@ -76,17 +77,18 @@ Problems?
76
77
  If you have a problem, please review the [FAQ](https://github.com/mperham/sidekiq/wiki/FAQ) and [Troubleshooting](https://github.com/mperham/sidekiq/wiki/Problems-and-Troubleshooting) wiki pages.
77
78
  Searching the [issues](https://github.com/mperham/sidekiq/issues) for your problem is also a good idea.
78
79
 
80
+ Sidekiq Pro and Sidekiq Enterprise customers get private email support. You can purchase at http://sidekiq.org; email support@contribsys.com for help.
81
+
79
82
  Useful resources:
80
83
 
81
84
  * Product documentation is in the [wiki](https://github.com/mperham/sidekiq/wiki).
82
85
  * Release announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
83
- * Here's a [Reddit forum](https://reddit.com/r/sidekiq) dedicated to Sidekiq discussion
84
86
  * The [Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow has lots of useful Q &amp; A.
85
87
 
86
- **No support via Twitter, 140 characters is not enough.**
88
+ **No support via Twitter**
87
89
 
88
90
  Every Friday morning is Sidekiq happy hour: I video chat and answer questions.
89
- See the [Sidekiq support page](http://sidekiq.org/support) for details.
91
+ See the [Sidekiq support page](http://sidekiq.org/support.html) for details.
90
92
 
91
93
  Thanks
92
94
  -----------------
data/Rakefile CHANGED
@@ -1,12 +1,9 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
+
3
4
  Rake::TestTask.new(:test) do |test|
4
5
  test.warning = true
5
6
  test.pattern = 'test/**/test_*.rb'
6
7
  end
7
8
 
8
- task :default => :test
9
-
10
- task :appraise do
11
- exec("cd myapp && rake appraise")
12
- end
9
+ task default: :test
@@ -1,99 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'fileutils'
4
+ require 'sidekiq/api'
5
+ require 'sidekiq/ctl'
4
6
 
5
- class Sidekiqctl
6
- DEFAULT_KILL_TIMEOUT = 10
7
-
8
- attr_reader :stage, :pidfile, :kill_timeout
9
-
10
- def self.print_usage
11
- puts "#{File.basename($0)} - stop a Sidekiq process from the command line."
12
- puts
13
- puts "Usage: #{File.basename($0)} <command> <pidfile> <kill_timeout>"
14
- puts " where <command> is either 'quiet' or 'stop'"
15
- puts " <pidfile> is path to a pidfile"
16
- puts " <kill_timeout> is number of seconds to wait until Sidekiq exits"
17
- puts " (default: #{Sidekiqctl::DEFAULT_KILL_TIMEOUT}), after which Sidekiq will be KILL'd"
18
- puts
19
- puts "Be sure to set the kill_timeout LONGER than Sidekiq's -t timeout. If you want"
20
- puts "to wait 60 seconds for jobs to finish, use `sidekiq -t 60` and `sidekiqctl stop"
21
- puts " path_to_pidfile 61`"
22
- puts
23
- end
24
-
25
- def initialize(stage, pidfile, timeout)
26
- @stage = stage
27
- @pidfile = pidfile
28
- @kill_timeout = timeout
29
-
30
- done('No pidfile given', :error) if !pidfile
31
- done("Pidfile #{pidfile} does not exist", :warn) if !File.exist?(pidfile)
32
- done('Invalid pidfile content', :error) if pid == 0
33
-
34
- fetch_process
35
-
36
- begin
37
- send(stage)
38
- rescue NoMethodError
39
- done "Invalid command: #{stage}", :error
40
- end
41
- end
42
-
43
- def fetch_process
44
- Process.kill(0, pid)
45
- rescue Errno::ESRCH
46
- done "Process doesn't exist", :error
47
- # We were not allowed to send a signal, but the process must have existed
48
- # when Process.kill() was called.
49
- rescue Errno::EPERM
50
- return pid
51
- end
52
-
53
- def done(msg, error = nil)
54
- puts msg
55
- exit(exit_signal(error))
56
- end
57
-
58
- def exit_signal(error)
59
- (error == :error) ? 1 : 0
60
- end
61
-
62
- def pid
63
- @pid ||= File.read(pidfile).to_i
64
- end
65
-
66
- def quiet
67
- `kill -USR1 #{pid}`
68
- end
69
-
70
- def stop
71
- `kill -TERM #{pid}`
72
- kill_timeout.times do
73
- begin
74
- Process.kill(0, pid)
75
- rescue Errno::ESRCH
76
- FileUtils.rm_f pidfile
77
- done 'Sidekiq shut down gracefully.'
78
- rescue Errno::EPERM
79
- done 'Not permitted to shut down Sidekiq.'
80
- end
81
- sleep 1
82
- end
83
- `kill -9 #{pid}`
84
- FileUtils.rm_f pidfile
85
- done 'Sidekiq shut down forcefully.'
86
- end
87
- alias_method :shutdown, :stop
88
- end
89
-
90
- if ARGV.length < 2
91
- Sidekiqctl.print_usage
7
+ if ARGV[0] == 'status'
8
+ Sidekiq::Ctl::Status.new.display(ARGV[1])
92
9
  else
93
- stage = ARGV[0]
94
- pidfile = ARGV[1]
95
- timeout = ARGV[2].to_i
96
- timeout = Sidekiqctl::DEFAULT_KILL_TIMEOUT if timeout == 0
10
+ if ARGV.length < 2
11
+ Sidekiq::Ctl.print_usage
12
+ else
13
+ stage = ARGV[0]
14
+ pidfile = ARGV[1]
15
+ timeout = ARGV[2].to_i
16
+ timeout = Sidekiq::Ctl::DEFAULT_KILL_TIMEOUT if timeout == 0
97
17
 
98
- Sidekiqctl.new(stage, pidfile, timeout)
18
+ Sidekiq::Ctl.new(stage, pidfile, timeout)
19
+ end
99
20
  end
@@ -46,7 +46,7 @@ end
46
46
  #}])
47
47
 
48
48
  self_read, self_write = IO.pipe
49
- %w(INT TERM USR1 USR2 TTIN).each do |sig|
49
+ %w(INT TERM TSTP TTIN).each do |sig|
50
50
  begin
51
51
  trap sig do
52
52
  self_write.puts(sig)
@@ -65,19 +65,14 @@ def handle_signal(launcher, sig)
65
65
  # http://jira.codehaus.org/browse/JRUBY-4637
66
66
  raise Interrupt
67
67
  when 'TERM'
68
- # Heroku sends TERM and then waits 10 seconds for process to exit.
68
+ # Heroku sends TERM and then waits 30 seconds for process to exit.
69
69
  raise Interrupt
70
- when 'USR1'
71
- Sidekiq.logger.info "Received USR1, no longer accepting new work"
70
+ when 'TSTP'
71
+ Sidekiq.logger.info "Received TSTP, no longer accepting new work"
72
72
  launcher.quiet
73
- when 'USR2'
74
- if Sidekiq.options[:logfile]
75
- Sidekiq.logger.info "Received USR2, reopening log file"
76
- Sidekiq::Logging.reopen_logs
77
- end
78
73
  when 'TTIN'
79
74
  Thread.list.each do |thread|
80
- Sidekiq.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}"
75
+ Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread['label']}"
81
76
  if thread.backtrace
82
77
  Sidekiq.logger.warn thread.backtrace.join("\n")
83
78
  else
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
  <% module_namespacing do -%>
3
3
  RSpec.describe <%= class_name %>Worker, type: :worker do
4
- pending "add some examples to (or delete) #{__FILE__}"
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
5
  end
6
6
  <% end -%>