sidekiq 3.3.1 → 3.3.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: 5ebae4a31efb6367e41c8b9a808252448ed678bb
4
- data.tar.gz: f32133f60e2b52b83653b83a0bb034a9fb649ec6
3
+ metadata.gz: 66911189b7648f87bf3ce6e11f5917d6b242ddcc
4
+ data.tar.gz: e21cbc6d3f73a9a25df7f2771248205ba457f453
5
5
  SHA512:
6
- metadata.gz: d439e1b3ac4a44c5f9d59a91289041241eb66659952b80cf10f1bce3c5a32b3d7972821e62430a21ab4a4ec20fdf0a6546dbbe5a127437a24e24355381cc6f39
7
- data.tar.gz: 4d199feb0af0d1c099f137f743b38ec56cd98110d10a1b8d2bad4dc6cbdc7afe1057a368ef7079eb92582edb9518a3584e4e1436a420419a1150a3b6510a1bf8
6
+ metadata.gz: 16d3851a53e70a270cfd7277817953fa54897dabf0f4f527308bcbcb769d4232d98466bac1477f820472a7cac361326da5563e696481f7a2963471c6cd3119b8
7
+ data.tar.gz: c687ab3be80e972fd2b98c6d2939c7509506a8516495eabb81d4ae92c6ec939203a28e4bfea99925bd8469f8035f8024010cc6e992aef97e9adc74a256b4b9c4
data/Changes.md CHANGED
@@ -1,8 +1,15 @@
1
+ 3.3.2
2
+ -----------
3
+
4
+ - Add Sidekiq::Stats#queues back
5
+ - Allows configuration of dead job set size and timeout [#2173, jonhyman]
6
+ - Refactor scheduler enqueuing so Sidekiq Pro can override it. [#2159]
7
+
1
8
  3.3.1
2
9
  -----------
3
10
 
4
11
  - Dumb down ActionMailer integration so it tries to deliver if possible [#2149]
5
- - Stringify Sidekiq.default_worker_options's keys [#2126]
12
+ - Stringify Sidekiq.default\_worker\_options's keys [#2126]
6
13
  - Add random integer to process identity [#2113, michaeldiscala]
7
14
  - Log Sidekiq Pro's Batch ID if available [#2076]
8
15
  - Refactor Processor Redis usage to avoid redis/redis-rb#490 [#2094]
@@ -1,19 +1,16 @@
1
1
  # Contributing
2
2
 
3
- First of all, thank you! I hope you find it worthwhile to help out with Sidekiq.
4
-
5
3
  ## Issues
6
4
 
7
- When opening an issue, please include a **backtrace** with your error.
5
+ When opening an issue:
8
6
 
9
- ## Code
7
+ * include the full **backtrace** with your error
8
+ * include your Sidekiq initializer
9
+ * list versions you are using: Ruby, Rails, Sidekiq, OS, etc.
10
10
 
11
- If you're interested in helping or contributing to Sidekiq, here's
12
- some known areas which need improvement:
11
+ It's always better to include more info rather than less.
13
12
 
14
- * The Web UI and sidekiq.org website could always use more polish. If you have an eye for design and an idea for improvement, please open an issue and let us know.
15
- * The [Sidekiq issue tracker](https://github.com/mperham/sidekiq/issues) usually has a few ideas
16
- * Your brilliant idea which I haven't listed!
13
+ ## Code
17
14
 
18
15
  It's always best to open an issue before investing a lot of time into a
19
16
  fix or new functionality. Functionality must meet my design goals and
@@ -22,8 +19,8 @@ your idea can best fit into Sidekiq.
22
19
 
23
20
  ## Legal
24
21
 
25
- By submitting a Pull Request, you disavow any rights or
26
- claims to any changes submitted to the Sidekiq project and assign the copyright of
22
+ By submitting a Pull Request, you disavow any rights or claims to any changes
23
+ submitted to the Sidekiq project and assign the copyright of
27
24
  those changes to Contributed Systems LLC.
28
25
 
29
26
  If you cannot or do not want to reassign those rights (your employment
@@ -31,5 +28,5 @@ contract for your employer may not allow this), you should not submit a PR.
31
28
  Open an issue and someone else can do the work.
32
29
 
33
30
  This is a legal way of saying "If you submit a PR to us, that code becomes ours".
34
- 99.9% of the time that's what you intend anyways; we hope it doesn't scare you away from contributing!
35
-
31
+ 99.9% of the time that's what you intend anyways; we hope it doesn't scare you
32
+ away from contributing.
@@ -1,10 +1,20 @@
1
1
  # Upgrading to Sidekiq Pro 2.0
2
2
 
3
- Sidekiq Pro 2.0 allows nested batches for more complex job workflows.
3
+ Sidekiq Pro 2.0 allows nested batches for more complex job workflows
4
+ and provides a new reliable scheduler which uses Lua to guarantee
5
+ atomicity and much higher performance.
6
+
4
7
  It also removes deprecated APIs, changes the batch data format and
5
8
  how features are activated. Read carefully to ensure your upgrade goes
6
9
  smoothly.
7
10
 
11
+ Sidekiq Pro 2.0 requires Sidekiq 3.3.2 or greater. Redis 2.8 is
12
+ recommended; Redis 2.4 or 2.6 will work but some functionality will not be
13
+ available.
14
+
15
+ **Note that you CANNOT go back to Pro 1.x once you've created batches
16
+ with 2.x. The new batches will not process correctly with 1.x.**
17
+
8
18
  ## Nested Batches
9
19
 
10
20
  Batches can now be nested within the `jobs` method.
@@ -68,17 +78,22 @@ savings but real world savings should be even greater.
68
78
  **There's no data migration required. Sidekiq Pro 2.0 transparently handles
69
79
  both old and new format.**
70
80
 
71
- **Note that you CANNOT go back to Pro 1.x once you've created batches
72
- with 2.x. The new batches will not process correctly with 1.x.**
73
-
74
81
  ## Reliability
75
82
 
76
- You no longer need to require anything to use Reliability features.
83
+ 2.0 brings a new reliable scheduler which uses Lua inside Redis so enqueuing
84
+ scheduled jobs is atomic. Benchmarks show it 50x faster when enqueuing
85
+ lots of jobs. **One caveat**: client-side middleware is not executed
86
+ for each job when enqueued with the reliable scheduler. No Sidekiq or
87
+ Sidekiq Pro functionality is affected by this change but some 3rd party
88
+ plugins might be.
89
+
90
+ **You no longer require anything to use the Reliability features.**
77
91
 
78
- * Activate reliable fetch:
92
+ * Activate reliable fetch and/or the new reliable scheduler:
79
93
  ```ruby
80
94
  Sidekiq.configure_server do |config|
81
95
  config.reliable_fetch!
96
+ config.reliable_scheduler!
82
97
  end
83
98
  ```
84
99
  * Activate reliable push:
@@ -88,7 +103,7 @@ Sidekiq::Client.reliable_push!
88
103
 
89
104
  ## Other Changes
90
105
 
91
- * You must require `sidekiq/notifications` if you want to use the
106
+ * You must require `sidekiq/pro/notifications` if you want to use the
92
107
  existing notification schemes. I don't recommend using them as the
93
108
  newer-style `Sidekiq::Batch#on` method is simpler and more flexible.
94
109
  * Several classes have been renamed. Generally these classes are ones
@@ -4,10 +4,10 @@ Sidekiq Pro Changelog
4
4
  Please see [http://sidekiq.org/pro](http://sidekiq.org/pro) for more details and how to buy.
5
5
 
6
6
 
7
- 2.0.0 (see mperham/sidekiq#2130 for progress)
7
+ 2.0.0 (unreleased)
8
8
  -----------
9
9
 
10
- - See [[Pro-2.0-Upgrade.md]] for thorough release notes.
10
+ - See [the Upgrade Notes](Pro-2.0-Upgrade.md) for detailed notes.
11
11
 
12
12
  1.9.2
13
13
  -----------
data/README.md CHANGED
@@ -1,7 +1,11 @@
1
1
  Sidekiq
2
2
  ==============
3
3
 
4
- [![Gem Version](https://badge.fury.io/rb/sidekiq.png)](https://rubygems.org/gems/sidekiq) [![Code Climate](https://codeclimate.com/github/mperham/sidekiq.png)](https://codeclimate.com/github/mperham/sidekiq) [![Build Status](https://travis-ci.org/mperham/sidekiq.png)](https://travis-ci.org/mperham/sidekiq) [![Coverage Status](https://coveralls.io/repos/mperham/sidekiq/badge.png?branch=master)](https://coveralls.io/r/mperham/sidekiq)
4
+ [![Gem Version](https://badge.fury.io/rb/sidekiq.png)](https://rubygems.org/gems/sidekiq)
5
+ [![Code Climate](https://codeclimate.com/github/mperham/sidekiq.png)](https://codeclimate.com/github/mperham/sidekiq)
6
+ [![Build Status](https://travis-ci.org/mperham/sidekiq.png)](https://travis-ci.org/mperham/sidekiq)
7
+ [![Coverage Status](https://coveralls.io/repos/mperham/sidekiq/badge.png?branch=master)](https://coveralls.io/r/mperham/sidekiq)
8
+ [![Gitter Chat](https://badges.gitter.im/mperham/sidekiq.png)](https://gitter.im/mperham/sidekiq)
5
9
 
6
10
 
7
11
  Simple, efficient background processing for Ruby.
@@ -60,7 +64,7 @@ More Information
60
64
  -----------------
61
65
 
62
66
  Please see the [sidekiq wiki](https://github.com/mperham/sidekiq/wiki) for the official documentation.
63
- [#sidekiq on irc.freenode.net](irc://irc.freenode.net/#sidekiq) is dedicated to this project,
67
+ [mperham/sidekiq on Gitter](https://gitter.im/mperham/sidekiq) is dedicated to this project,
64
68
  but bug reports or feature requests suggestions should still go through [issues on Github](https://github.com/mperham/sidekiq/issues). Release announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
65
69
 
66
70
  You may also find useful a [Google Group](https://groups.google.com/forum/#!forum/sidekiq) dedicated to Sidekiq discussion and [a Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow.
@@ -71,7 +75,7 @@ Problems?
71
75
 
72
76
  **Please do not directly email any Sidekiq committers with questions or problems.** A community is best served when discussions are held in public.
73
77
 
74
- 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. Searching the issues for your problem is also a good idea. If that doesn't help, feel free to email the Sidekiq mailing list or open a new issue.
78
+ 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. Searching the issues for your problem is also a good idea. If that doesn't help, feel free to email the Sidekiq mailing list, chat in Gitter, or open a new issue.
75
79
  The mailing list is the preferred place to ask questions on usage. If you are encountering what you think is a bug, please open an issue.
76
80
 
77
81
 
@@ -25,7 +25,9 @@ module Sidekiq
25
25
  startup: [],
26
26
  quiet: [],
27
27
  shutdown: [],
28
- }
28
+ },
29
+ dead_max_jobs: 10_000,
30
+ dead_timeout_in_seconds: 180 * 24 * 60 * 60 # 6 months
29
31
  }
30
32
 
31
33
  def self.❨╯°□°❩╯︵┻━┻
@@ -43,6 +43,10 @@ module Sidekiq
43
43
  stat :default_queue_latency
44
44
  end
45
45
 
46
+ def queues
47
+ Sidekiq::Stats::Queues.new.lengths
48
+ end
49
+
46
50
  def fetch_stats!
47
51
  pipe1_res = Sidekiq.redis do |conn|
48
52
  conn.pipelined do
@@ -395,8 +399,8 @@ module Sidekiq
395
399
  Sidekiq.redis do |conn|
396
400
  conn.multi do
397
401
  conn.zadd('dead', now, message)
398
- conn.zremrangebyscore('dead', '-inf', now - DeadSet::TIMEOUT)
399
- conn.zremrangebyrank('dead', 0, - DeadSet::MAX_JOBS)
402
+ conn.zremrangebyscore('dead', '-inf', now - DeadSet.timeout)
403
+ conn.zremrangebyrank('dead', 0, - DeadSet.max_jobs)
400
404
  end
401
405
  end
402
406
  end
@@ -589,9 +593,6 @@ module Sidekiq
589
593
  # Allows enumeration of dead jobs within Sidekiq.
590
594
  #
591
595
  class DeadSet < JobSet
592
- TIMEOUT = 180 * 24 * 60 * 60 # 6 months
593
- MAX_JOBS = 10_000
594
-
595
596
  def initialize
596
597
  super 'dead'
597
598
  end
@@ -601,6 +602,14 @@ module Sidekiq
601
602
  each(&:retry)
602
603
  end
603
604
  end
605
+
606
+ def self.max_jobs
607
+ Sidekiq.options[:dead_max_jobs]
608
+ end
609
+
610
+ def self.timeout
611
+ Sidekiq.options[:dead_timeout_in_seconds]
612
+ end
604
613
  end
605
614
 
606
615
  ##
@@ -156,8 +156,8 @@ module Sidekiq
156
156
  Sidekiq.redis do |conn|
157
157
  conn.multi do
158
158
  conn.zadd('dead', now, payload)
159
- conn.zremrangebyscore('dead', '-inf', now - DeadSet::TIMEOUT)
160
- conn.zremrangebyrank('dead', 0, -DeadSet::MAX_JOBS)
159
+ conn.zremrangebyscore('dead', '-inf', now - DeadSet.timeout)
160
+ conn.zremrangebyrank('dead', 0, -DeadSet.max_jobs)
161
161
  end
162
162
  end
163
163
  end
@@ -5,8 +5,32 @@ require 'sidekiq/api'
5
5
 
6
6
  module Sidekiq
7
7
  module Scheduled
8
+ SETS = %w(retry schedule)
8
9
 
9
- INITIAL_WAIT = 10
10
+ class Enq
11
+ def enqueue_jobs(now=Time.now.to_f.to_s, sorted_sets=SETS)
12
+ # A job's "score" in Redis is the time at which it should be processed.
13
+ # Just check Redis for the set of jobs with a timestamp before now.
14
+ Sidekiq.redis do |conn|
15
+ sorted_sets.each do |sorted_set|
16
+ # Get the next item in the queue if it's score (time to execute) is <= now.
17
+ # We need to go through the list one at a time to reduce the risk of something
18
+ # going wrong between the time jobs are popped from the scheduled queue and when
19
+ # they are pushed onto a work queue and losing the jobs.
20
+ while job = conn.zrangebyscore(sorted_set, '-inf', now, :limit => [0, 1]).first do
21
+
22
+ # Pop item off the queue and add it to the work queue. If the job can't be popped from
23
+ # the queue, it's because another process already popped it so we can move on to the
24
+ # next one.
25
+ if conn.zrem(sorted_set, job)
26
+ Sidekiq::Client.push(Sidekiq.load_json(job))
27
+ Sidekiq::Logging.logger.debug { "enqueued #{sorted_set}: #{job}" }
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
10
34
 
11
35
  ##
12
36
  # The Poller checks Redis every N seconds for jobs in the retry or scheduled
@@ -17,34 +41,18 @@ module Sidekiq
17
41
  include Util
18
42
  include Actor
19
43
 
20
- SETS = %w(retry schedule)
44
+ INITIAL_WAIT = 10
45
+
46
+ def initialize
47
+ @enq = (Sidekiq.options[:scheduled_enq] || Sidekiq::Scheduled::Enq).new
48
+ end
21
49
 
22
50
  def poll(first_time=false)
23
51
  watchdog('scheduling poller thread died!') do
24
52
  initial_wait if first_time
25
53
 
26
54
  begin
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.
29
- now = Time.now.to_f.to_s
30
- Sidekiq.redis do |conn|
31
- SETS.each do |sorted_set|
32
- # Get the next item in the queue if it's score (time to execute) is <= now.
33
- # We need to go through the list one at a time to reduce the risk of something
34
- # going wrong between the time jobs are popped from the scheduled queue and when
35
- # they are pushed onto a work queue and losing the jobs.
36
- while job = conn.zrangebyscore(sorted_set, '-inf', now, :limit => [0, 1]).first do
37
-
38
- # Pop item off the queue and add it to the work queue. If the job can't be popped from
39
- # the queue, it's because another process already popped it so we can move on to the
40
- # next one.
41
- if conn.zrem(sorted_set, job)
42
- Sidekiq::Client.push(Sidekiq.load_json(job))
43
- logger.debug { "enqueued #{sorted_set}: #{job}" }
44
- end
45
- end
46
- end
47
- end
55
+ @enq.enqueue_jobs
48
56
  rescue => ex
49
57
  # Most likely a problem with redis networking.
50
58
  # Punt and try again at the next interval
@@ -85,10 +93,10 @@ module Sidekiq
85
93
 
86
94
  def initial_wait
87
95
  begin
88
- # Have all processes sleep between 10-15 seconds. 10 seconds
89
- # to give time for the heartbeat to register and 5 random seconds
90
- # to ensure they don't all hit Redis at the same time.
91
- sleep(INITIAL_WAIT)
96
+ # Have all processes sleep between 5-15 seconds. 10 seconds
97
+ # to give time for the heartbeat to register (if the poll interval is going to be calculated by the number
98
+ # of workers), and 5 random seconds to ensure they don't all hit Redis at the same time.
99
+ sleep(INITIAL_WAIT) unless Sidekiq.options[:poll_interval]
92
100
  sleep(5 * rand)
93
101
  rescue Celluloid::Task::TerminatedError
94
102
  # Hit Ctrl-C when Sidekiq is finished booting and we have a chance
@@ -1,3 +1,3 @@
1
1
  module Sidekiq
2
- VERSION = "3.3.1"
2
+ VERSION = "3.3.2"
3
3
  end
@@ -76,6 +76,10 @@ class TestApi < Sidekiq::Test
76
76
  end
77
77
 
78
78
  describe "queues" do
79
+ it "returns all queues" do
80
+ assert_equal Sidekiq::Stats.new.queues, Sidekiq::Stats::Queues.new.lengths
81
+ end
82
+
79
83
  it "is initially empty" do
80
84
  s = Sidekiq::Stats::Queues.new
81
85
  assert_equal 0, s.lengths.size
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.3.1
4
+ version: 3.3.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: 2015-01-27 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis