sidekiq 5.0.5 → 5.2.1
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 +4 -4
- data/.github/issue_template.md +3 -1
- data/.travis.yml +5 -4
- data/Changes.md +53 -1
- data/Ent-Changes.md +21 -0
- data/Gemfile +10 -28
- data/LICENSE +1 -1
- data/Pro-4.0-Upgrade.md +35 -0
- data/Pro-Changes.md +86 -0
- data/README.md +4 -2
- data/Rakefile +0 -4
- data/bin/sidekiqload +1 -1
- data/lib/sidekiq/api.rb +65 -29
- data/lib/sidekiq/cli.rb +54 -24
- data/lib/sidekiq/client.rb +32 -32
- data/lib/sidekiq/delay.rb +1 -0
- data/lib/sidekiq/exception_handler.rb +2 -4
- data/lib/sidekiq/fetch.rb +1 -1
- data/lib/sidekiq/job_logger.rb +2 -1
- data/lib/sidekiq/job_retry.rb +18 -5
- data/lib/sidekiq/launcher.rb +17 -11
- data/lib/sidekiq/logging.rb +9 -5
- data/lib/sidekiq/manager.rb +2 -3
- data/lib/sidekiq/middleware/server/active_record.rb +2 -1
- data/lib/sidekiq/processor.rb +33 -18
- data/lib/sidekiq/rails.rb +6 -0
- data/lib/sidekiq/redis_connection.rb +11 -3
- data/lib/sidekiq/scheduled.rb +35 -8
- data/lib/sidekiq/testing.rb +4 -4
- data/lib/sidekiq/util.rb +6 -2
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web/action.rb +2 -2
- data/lib/sidekiq/web/application.rb +18 -2
- data/lib/sidekiq/web/helpers.rb +7 -5
- data/lib/sidekiq/web/router.rb +10 -10
- data/lib/sidekiq/web.rb +4 -4
- data/lib/sidekiq/worker.rb +7 -7
- data/lib/sidekiq.rb +20 -13
- data/sidekiq.gemspec +3 -8
- data/web/assets/javascripts/application.js +0 -0
- data/web/assets/stylesheets/application.css +0 -0
- data/web/assets/stylesheets/bootstrap.css +2 -2
- data/web/locales/en.yml +1 -0
- data/web/locales/es.yml +4 -3
- data/web/locales/ja.yml +5 -3
- data/web/views/_footer.erb +3 -0
- data/web/views/layout.erb +1 -1
- data/web/views/queues.erb +2 -0
- metadata +8 -89
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b5307056552014ab284241c16aa83a8d334d31b
|
4
|
+
data.tar.gz: acc9588810366d8c6dbb03d3c5cbe140a169f501
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b051912f610e763585e847a991cee6e684d4b27111f91cfe395a1e02539424e931f5ba16141e30a06c3dcf9de3c54db578be47a9fcd629222b81d8295f7c12a
|
7
|
+
data.tar.gz: 836cc95385406201ad9e26363698d838381ef993e75034bfc030c4ef0d2821c80e3a4612c5a7ec8bfca1d7acdadd02bcf29f5b979d56ece6752686f6293216ef
|
data/.github/issue_template.md
CHANGED
@@ -4,6 +4,8 @@ Sidekiq / Pro / Enterprise version(s):
|
|
4
4
|
Please include your initializer and any error message with the full backtrace.
|
5
5
|
|
6
6
|
Are you using an old version?
|
7
|
-
Have you checked the
|
7
|
+
Have you checked the changelogs to see if your issue has been fixed in a later version?
|
8
8
|
|
9
9
|
https://github.com/mperham/sidekiq/blob/master/Changes.md
|
10
|
+
https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md
|
11
|
+
https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md
|
data/.travis.yml
CHANGED
data/Changes.md
CHANGED
@@ -2,12 +2,64 @@
|
|
2
2
|
|
3
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)
|
4
4
|
|
5
|
-
|
5
|
+
5.2.1
|
6
|
+
-----------
|
7
|
+
|
8
|
+
- Fix concurrent modification error during heartbeat [#3921]
|
9
|
+
|
10
|
+
5.2.0
|
11
|
+
-----------
|
12
|
+
|
13
|
+
- **Decrease default concurrency from 25 to 10** [#3892]
|
14
|
+
- Verify connection pool sizing upon startup [#3917]
|
15
|
+
- Smoother scheduling for large Sidekiq clusters [#3889]
|
16
|
+
- Switch Sidekiq::Testing impl from alias\_method to Module#prepend, for resiliency [#3852]
|
17
|
+
- Update Sidekiq APIs to use SCAN for scalability [#3848, ffiller]
|
18
|
+
- Remove concurrent-ruby gem dependency [#3830]
|
19
|
+
- Optimize Web UI's bootstrap.css [#3914]
|
20
|
+
|
21
|
+
5.1.3
|
22
|
+
-----------
|
23
|
+
|
24
|
+
- Fix version comparison so Ruby 2.2.10 works. [#3808, nateberkopec]
|
25
|
+
|
26
|
+
5.1.2
|
27
|
+
-----------
|
28
|
+
|
29
|
+
- Add link to docs in Web UI footer
|
30
|
+
- Fix crash on Ctrl-C in Windows [#3775, Bernica]
|
31
|
+
- Remove `freeze` calls on String constants. This is superfluous with Ruby
|
32
|
+
2.3+ and `frozen_string_literal: true`. [#3759]
|
33
|
+
- Fix use of AR middleware outside of Rails [#3787]
|
34
|
+
- Sidekiq::Worker `sidekiq_retry_in` block can now return nil or 0 to use
|
35
|
+
the default backoff delay [#3796, dsalahutdinov]
|
36
|
+
|
37
|
+
5.1.1
|
38
|
+
-----------
|
39
|
+
|
40
|
+
- Fix Web UI incompatibility with Redis 3.x gem [#3749]
|
41
|
+
|
42
|
+
5.1.0
|
43
|
+
-----------
|
44
|
+
|
45
|
+
- **NEW** Global death handlers - called when your job exhausts all
|
46
|
+
retries and dies. Now you can take action when a job fails permanently. [#3721]
|
47
|
+
- **NEW** Enable ActiveRecord query cache within jobs by default [#3718, sobrinho]
|
48
|
+
This will prevent duplicate SELECTS; cache is cleared upon any UPDATE/INSERT/DELETE.
|
49
|
+
See the issue for how to bypass the cache or disable it completely.
|
50
|
+
- Scheduler timing is now more accurate, 15 -> 5 seconds [#3734]
|
51
|
+
- Exceptions during the :startup event will now kill the process [#3717]
|
52
|
+
- Make `Sidekiq::Client.via` reentrant [#3715]
|
53
|
+
- Fix use of Sidekiq logger outside of the server process [#3714]
|
54
|
+
- Tweak `constantize` to better match Rails class lookup. [#3701, caffeinated-tech]
|
55
|
+
|
56
|
+
5.0.5
|
6
57
|
-----------
|
7
58
|
|
8
59
|
- Update gemspec to allow newer versions of the Redis gem [#3617]
|
9
60
|
- Refactor Worker.set so it can be memoized [#3602]
|
10
61
|
- Fix display of Redis URL in web footer, broken in 5.0.3 [#3560]
|
62
|
+
- Update `Sidekiq::Job#display_args` to avoid mutation [#3621]
|
11
63
|
|
12
64
|
5.0.4
|
13
65
|
-----------
|
data/Ent-Changes.md
CHANGED
@@ -4,6 +4,27 @@
|
|
4
4
|
|
5
5
|
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
6
6
|
|
7
|
+
HEAD
|
8
|
+
-------------
|
9
|
+
|
10
|
+
- Add support for sidekiqswarm memory monitoring on FreeBSD [#3884]
|
11
|
+
|
12
|
+
1.7.1
|
13
|
+
-------------
|
14
|
+
|
15
|
+
- Fix Lua error in concurrent rate limiter under heavy contention
|
16
|
+
- Remove superfluous `freeze` calls on Strings [#3759]
|
17
|
+
|
18
|
+
1.7.0
|
19
|
+
-------------
|
20
|
+
|
21
|
+
- **NEW FEATURE** [Rolling restarts](https://github.com/mperham/sidekiq/wiki/Ent-Rolling-Restarts) - great for long running jobs!
|
22
|
+
- Adjust middleware so unique jobs that don't push aren't registered in a Batch [#3662]
|
23
|
+
- Add new unlimited rate limiter, useful for testing [#3743]
|
24
|
+
```ruby
|
25
|
+
limiter = Sidekiq::Limiter.unlimited(...any args...)
|
26
|
+
```
|
27
|
+
|
7
28
|
1.6.1
|
8
29
|
-------------
|
9
30
|
|
data/Gemfile
CHANGED
@@ -1,32 +1,14 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
|
5
|
-
gem "hiredis"
|
6
|
-
gem '
|
7
|
-
|
8
|
-
|
9
|
-
gem '
|
10
|
-
|
11
|
-
|
12
|
-
gem 'redis-namespace'
|
13
|
-
|
14
|
-
platforms :rbx do
|
15
|
-
gem 'rubysl', '~> 2.0' # if using anything in the ruby standard library
|
16
|
-
gem 'psych' # if using yaml
|
17
|
-
gem 'rubinius-developer_tools' # if using any of coverage, debugger, profiler
|
18
|
-
end
|
19
|
-
|
20
|
-
platforms :ruby do
|
21
|
-
gem 'sqlite3'
|
4
|
+
# load testing
|
5
|
+
#gem "hiredis"
|
6
|
+
#gem 'toxiproxy'
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'rails', '>= 5.0.1'
|
10
|
+
gem 'minitest'
|
11
|
+
gem 'rake'
|
12
|
+
gem 'redis-namespace'
|
13
|
+
gem 'simplecov'
|
22
14
|
end
|
23
|
-
|
24
|
-
platforms :mri do
|
25
|
-
gem 'pry-byebug'
|
26
|
-
gem 'ruby-prof'
|
27
|
-
end
|
28
|
-
|
29
|
-
#platforms :jruby do
|
30
|
-
#gem 'jruby-openssl'
|
31
|
-
#gem 'activerecord-jdbcsqlite3-adapter'
|
32
|
-
#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
|
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.
|
data/Pro-4.0-Upgrade.md
ADDED
@@ -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
|
+
|
data/Pro-Changes.md
CHANGED
@@ -4,6 +4,92 @@
|
|
4
4
|
|
5
5
|
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
6
6
|
|
7
|
+
4.0.3
|
8
|
+
---------
|
9
|
+
|
10
|
+
- Add at\_exit handler to push any saved jobs in `reliable_push` when exiting. [#3823]
|
11
|
+
- Implement batch death callback. This is fired the first time a job within a batch dies. [#3841]
|
12
|
+
```ruby
|
13
|
+
batch = Sidekiq::Batch.new
|
14
|
+
batch.on(:death, ...)
|
15
|
+
```
|
16
|
+
|
17
|
+
4.0.2
|
18
|
+
---------
|
19
|
+
|
20
|
+
- Remove super\_fetch edge case leading to an unnecessary `sleep(1)`
|
21
|
+
call and resulting latency [#3790]
|
22
|
+
- Fix possible bad statsd metric call on super\_fetch startup
|
23
|
+
- Remove superfluous `freeze` calls on Strings [#3759]
|
24
|
+
|
25
|
+
4.0.1
|
26
|
+
---------
|
27
|
+
|
28
|
+
- Fix incompatibility with the statsd-ruby gem [#3740]
|
29
|
+
|
30
|
+
4.0.0
|
31
|
+
---------
|
32
|
+
|
33
|
+
- See the [Sidekiq Pro 4.0](Pro-4.0-Upgrade.md) release notes.
|
34
|
+
|
35
|
+
|
36
|
+
3.7.1
|
37
|
+
---------
|
38
|
+
|
39
|
+
- Deprecate timed\_fetch. Switch to super\_fetch:
|
40
|
+
```ruby
|
41
|
+
config.super_fetch!
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
3.7.0
|
46
|
+
---------
|
47
|
+
|
48
|
+
- Refactor batch job success/failure to gracefully handle several edge
|
49
|
+
cases with regard to Sidekiq::Shutdown. This should greatly reduce
|
50
|
+
the chances of seeing the long-standing "negative pending count" problem. [#3710]
|
51
|
+
|
52
|
+
|
53
|
+
3.6.1
|
54
|
+
---------
|
55
|
+
|
56
|
+
- Add support for Datadog::Statsd, it is the recommended Statsd client. [#3699]
|
57
|
+
```ruby
|
58
|
+
Sidekiq::Pro.dogstatsd = ->{ Datadog::Statsd.new("metrics.example.com", 8125) }
|
59
|
+
```
|
60
|
+
- Size the statsd connection pool based on Sidekiq's concurrency [#3700]
|
61
|
+
|
62
|
+
|
63
|
+
3.6.0
|
64
|
+
---------
|
65
|
+
|
66
|
+
This release overhauls the Statsd metrics support and adds more
|
67
|
+
metrics for tracking Pro feature usage. In your initializer:
|
68
|
+
```ruby
|
69
|
+
Sidekiq::Pro.statsd = ->{ ::Statsd.new("127.0.0.1", 8125) }
|
70
|
+
```
|
71
|
+
Sidekiq Pro will emit more metrics to Statsd:
|
72
|
+
```
|
73
|
+
jobs.expired - when a job is expired
|
74
|
+
jobs.recovered.push - when a job is recovered by reliable_push after network outage
|
75
|
+
jobs.recovered.fetch - when a job is recovered by super_fetch after process crash
|
76
|
+
batch.created - when a batch is created
|
77
|
+
batch.complete - when a batch is completed
|
78
|
+
batch.success - when a batch is successful
|
79
|
+
```
|
80
|
+
Sidekiq Pro's existing Statsd middleware has been rewritten to leverage the new API.
|
81
|
+
Everything should be backwards compatible with one deprecation notice.
|
82
|
+
|
83
|
+
|
84
|
+
3.5.4
|
85
|
+
---------
|
86
|
+
|
87
|
+
- Fix case in SuperFetch where Redis downtime can lead to processor thread death [#3684]
|
88
|
+
- Fix case where TimedFetch might not recover some pending jobs
|
89
|
+
- Fix edge case in Batch::Status#poll leading to premature completion [#3640]
|
90
|
+
- Adjust scan API to check 100 elements at a time, to minimize network round trips
|
91
|
+
when scanning large sets.
|
92
|
+
|
7
93
|
3.5.3
|
8
94
|
---------
|
9
95
|
|
data/README.md
CHANGED
@@ -77,16 +77,18 @@ Problems?
|
|
77
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.
|
78
78
|
Searching the [issues](https://github.com/mperham/sidekiq/issues) for your problem is also a good idea.
|
79
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
|
+
|
80
82
|
Useful resources:
|
81
83
|
|
82
84
|
* Product documentation is in the [wiki](https://github.com/mperham/sidekiq/wiki).
|
83
85
|
* Release announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
|
84
86
|
* The [Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow has lots of useful Q & A.
|
85
87
|
|
86
|
-
**No support via Twitter
|
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
data/bin/sidekiqload
CHANGED
@@ -72,7 +72,7 @@ def handle_signal(launcher, sig)
|
|
72
72
|
launcher.quiet
|
73
73
|
when 'TTIN'
|
74
74
|
Thread.list.each do |thread|
|
75
|
-
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']}"
|
76
76
|
if thread.backtrace
|
77
77
|
Sidekiq.logger.warn thread.backtrace.join("\n")
|
78
78
|
else
|
data/lib/sidekiq/api.rb
CHANGED
@@ -1,9 +1,24 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
require 'sidekiq'
|
4
3
|
|
5
4
|
module Sidekiq
|
5
|
+
|
6
|
+
module RedisScanner
|
7
|
+
def sscan(conn, key)
|
8
|
+
cursor = '0'
|
9
|
+
result = []
|
10
|
+
loop do
|
11
|
+
cursor, values = conn.sscan(key, cursor)
|
12
|
+
result.push(*values)
|
13
|
+
break if cursor == '0'
|
14
|
+
end
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
6
19
|
class Stats
|
20
|
+
include RedisScanner
|
21
|
+
|
7
22
|
def initialize
|
8
23
|
fetch_stats!
|
9
24
|
end
|
@@ -51,33 +66,39 @@ module Sidekiq
|
|
51
66
|
def fetch_stats!
|
52
67
|
pipe1_res = Sidekiq.redis do |conn|
|
53
68
|
conn.pipelined do
|
54
|
-
conn.get('stat:processed'
|
55
|
-
conn.get('stat:failed'
|
56
|
-
conn.zcard('schedule'
|
57
|
-
conn.zcard('retry'
|
58
|
-
conn.zcard('dead'
|
59
|
-
conn.scard('processes'
|
60
|
-
conn.lrange('queue:default'
|
61
|
-
conn.smembers('processes'.freeze)
|
62
|
-
conn.smembers('queues'.freeze)
|
69
|
+
conn.get('stat:processed')
|
70
|
+
conn.get('stat:failed')
|
71
|
+
conn.zcard('schedule')
|
72
|
+
conn.zcard('retry')
|
73
|
+
conn.zcard('dead')
|
74
|
+
conn.scard('processes')
|
75
|
+
conn.lrange('queue:default', -1, -1)
|
63
76
|
end
|
64
77
|
end
|
65
78
|
|
79
|
+
processes = Sidekiq.redis do |conn|
|
80
|
+
sscan(conn, 'processes')
|
81
|
+
end
|
82
|
+
|
83
|
+
queues = Sidekiq.redis do |conn|
|
84
|
+
sscan(conn, 'queues')
|
85
|
+
end
|
86
|
+
|
66
87
|
pipe2_res = Sidekiq.redis do |conn|
|
67
88
|
conn.pipelined do
|
68
|
-
|
69
|
-
|
89
|
+
processes.each {|key| conn.hget(key, 'busy') }
|
90
|
+
queues.each {|queue| conn.llen("queue:#{queue}") }
|
70
91
|
end
|
71
92
|
end
|
72
93
|
|
73
|
-
s =
|
94
|
+
s = processes.size
|
74
95
|
workers_size = pipe2_res[0...s].map(&:to_i).inject(0, &:+)
|
75
96
|
enqueued = pipe2_res[s..-1].map(&:to_i).inject(0, &:+)
|
76
97
|
|
77
98
|
default_queue_latency = if (entry = pipe1_res[6].first)
|
78
99
|
job = Sidekiq.load_json(entry) rescue {}
|
79
100
|
now = Time.now.to_f
|
80
|
-
thence = job['enqueued_at'
|
101
|
+
thence = job['enqueued_at'] || now
|
81
102
|
now - thence
|
82
103
|
else
|
83
104
|
0
|
@@ -117,9 +138,11 @@ module Sidekiq
|
|
117
138
|
end
|
118
139
|
|
119
140
|
class Queues
|
141
|
+
include RedisScanner
|
142
|
+
|
120
143
|
def lengths
|
121
144
|
Sidekiq.redis do |conn|
|
122
|
-
queues = conn
|
145
|
+
queues = sscan(conn, 'queues')
|
123
146
|
|
124
147
|
lengths = conn.pipelined do
|
125
148
|
queues.each do |queue|
|
@@ -163,7 +186,7 @@ module Sidekiq
|
|
163
186
|
|
164
187
|
while i < @days_previous
|
165
188
|
date = @start_date - i
|
166
|
-
datestr = date.strftime("%Y-%m-%d"
|
189
|
+
datestr = date.strftime("%Y-%m-%d")
|
167
190
|
keys << "stat:#{stat}:#{datestr}"
|
168
191
|
dates << datestr
|
169
192
|
i += 1
|
@@ -199,18 +222,19 @@ module Sidekiq
|
|
199
222
|
#
|
200
223
|
class Queue
|
201
224
|
include Enumerable
|
225
|
+
extend RedisScanner
|
202
226
|
|
203
227
|
##
|
204
228
|
# Return all known queues within Redis.
|
205
229
|
#
|
206
230
|
def self.all
|
207
|
-
Sidekiq.redis { |c| c
|
231
|
+
Sidekiq.redis { |c| sscan(c, 'queues') }.sort.map { |q| Sidekiq::Queue.new(q) }
|
208
232
|
end
|
209
233
|
|
210
234
|
attr_reader :name
|
211
235
|
|
212
236
|
def initialize(name="default")
|
213
|
-
@name = name
|
237
|
+
@name = name.to_s
|
214
238
|
@rname = "queue:#{name}"
|
215
239
|
end
|
216
240
|
|
@@ -273,7 +297,7 @@ module Sidekiq
|
|
273
297
|
Sidekiq.redis do |conn|
|
274
298
|
conn.multi do
|
275
299
|
conn.del(@rname)
|
276
|
-
conn.srem("queues"
|
300
|
+
conn.srem("queues", name)
|
277
301
|
end
|
278
302
|
end
|
279
303
|
end
|
@@ -349,9 +373,9 @@ module Sidekiq
|
|
349
373
|
job_args
|
350
374
|
end
|
351
375
|
else
|
352
|
-
if self['encrypt'
|
376
|
+
if self['encrypt']
|
353
377
|
# no point in showing 150+ bytes of random garbage
|
354
|
-
args[-1] = '[encrypted data]'
|
378
|
+
args[-1] = '[encrypted data]'
|
355
379
|
end
|
356
380
|
args
|
357
381
|
end
|
@@ -548,7 +572,7 @@ module Sidekiq
|
|
548
572
|
end
|
549
573
|
break if elements.empty?
|
550
574
|
page -= 1
|
551
|
-
elements.each do |element, score|
|
575
|
+
elements.reverse.each do |element, score|
|
552
576
|
yield SortedEntry.new(self, score, element)
|
553
577
|
end
|
554
578
|
offset_size = initial_size - @_size
|
@@ -656,7 +680,7 @@ module Sidekiq
|
|
656
680
|
super 'dead'
|
657
681
|
end
|
658
682
|
|
659
|
-
def kill(message)
|
683
|
+
def kill(message, opts={})
|
660
684
|
now = Time.now.to_f
|
661
685
|
Sidekiq.redis do |conn|
|
662
686
|
conn.multi do
|
@@ -665,6 +689,16 @@ module Sidekiq
|
|
665
689
|
conn.zremrangebyrank(name, 0, - self.class.max_jobs)
|
666
690
|
end
|
667
691
|
end
|
692
|
+
|
693
|
+
if opts[:notify_failure] != false
|
694
|
+
job = Sidekiq.load_json(message)
|
695
|
+
r = RuntimeError.new("Job killed by API")
|
696
|
+
r.set_backtrace(caller)
|
697
|
+
Sidekiq.death_handlers.each do |handle|
|
698
|
+
handle.call(job, r)
|
699
|
+
end
|
700
|
+
end
|
701
|
+
true
|
668
702
|
end
|
669
703
|
|
670
704
|
def retry_all
|
@@ -691,17 +725,18 @@ module Sidekiq
|
|
691
725
|
#
|
692
726
|
class ProcessSet
|
693
727
|
include Enumerable
|
728
|
+
include RedisScanner
|
694
729
|
|
695
730
|
def initialize(clean_plz=true)
|
696
|
-
|
731
|
+
cleanup if clean_plz
|
697
732
|
end
|
698
733
|
|
699
734
|
# Cleans up dead processes recorded in Redis.
|
700
735
|
# Returns the number of processes cleaned.
|
701
|
-
def
|
736
|
+
def cleanup
|
702
737
|
count = 0
|
703
738
|
Sidekiq.redis do |conn|
|
704
|
-
procs = conn
|
739
|
+
procs = sscan(conn, 'processes').sort
|
705
740
|
heartbeats = conn.pipelined do
|
706
741
|
procs.each do |key|
|
707
742
|
conn.hget(key, 'info')
|
@@ -721,7 +756,7 @@ module Sidekiq
|
|
721
756
|
end
|
722
757
|
|
723
758
|
def each
|
724
|
-
procs = Sidekiq.redis { |conn| conn
|
759
|
+
procs = Sidekiq.redis { |conn| sscan(conn, 'processes') }.sort
|
725
760
|
|
726
761
|
Sidekiq.redis do |conn|
|
727
762
|
# We're making a tradeoff here between consuming more memory instead of
|
@@ -856,10 +891,11 @@ module Sidekiq
|
|
856
891
|
#
|
857
892
|
class Workers
|
858
893
|
include Enumerable
|
894
|
+
include RedisScanner
|
859
895
|
|
860
896
|
def each
|
861
897
|
Sidekiq.redis do |conn|
|
862
|
-
procs = conn
|
898
|
+
procs = sscan(conn, 'processes')
|
863
899
|
procs.sort.each do |key|
|
864
900
|
valid, workers = conn.pipelined do
|
865
901
|
conn.exists(key)
|
@@ -881,7 +917,7 @@ module Sidekiq
|
|
881
917
|
# which can easily get out of sync with crashy processes.
|
882
918
|
def size
|
883
919
|
Sidekiq.redis do |conn|
|
884
|
-
procs = conn
|
920
|
+
procs = sscan(conn, 'processes')
|
885
921
|
if procs.empty?
|
886
922
|
0
|
887
923
|
else
|