sidekiq 7.2.1 → 7.2.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
  SHA256:
3
- metadata.gz: 34d69bb09eb124a8fd4710af9972bdb6a0cd74429bc3e61cdccdae683a4a0203
4
- data.tar.gz: 8a37c7f172e4efabb061f980a73547d7245585574133b07d159f0412e49dd362
3
+ metadata.gz: 67dd3e4a49f94aa711fa9baa0caac22c992b5c0a6a04a1cade9426f9a4a9341b
4
+ data.tar.gz: 224649c4a61110b9600f70f3ccd568360642e74330fc7503f6ac03bc57f638dd
5
5
  SHA512:
6
- metadata.gz: dbb63070d419ad3d2b8192b2864ff4608288c00fe51c7e79e4a3faafd33665cce0c92ece38f9cd2a30ae4b7ff7e66debaf894198b054b88c5d0b5d5ee3790153
7
- data.tar.gz: 8ba7a30ebdd19734a7cc64031a6eb63e4f317de0ae652bed324c272fd57f422186add097b38ab88aaa2a0a925de6b0845d18739691cbd9e9f2e90f3d79bb9e0a
6
+ metadata.gz: 20154e18f4d51e19b68946543f4523ac452f463ef7b8f2e4445bdb1d2bf518902e94edefc9d2a4f5771c33bdc5003b5b4b55fab05495d7756f90ebdc0bfbe0b9
7
+ data.tar.gz: 510fa35d3b8657b1e8e6b23bc940d0a32ae64d0e09331981728b23ea1548d2b000f1943ee39b2b2459500d86c4b3a3cd9a8bf2142ebd82ecdbdbfac75a0d521f
data/Changes.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  [Sidekiq Changes](https://github.com/sidekiq/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/sidekiq/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/sidekiq/sidekiq/blob/main/Ent-Changes.md)
4
4
 
5
+ HEAD
6
+ ----------
7
+
8
+ - Add `Process.warmup` call in Ruby 3.3+
9
+ - Batch jobs now skip transactional push [#6160]
10
+
5
11
  7.2.1
6
12
  ----------
7
13
 
data/README.md CHANGED
@@ -14,11 +14,11 @@ Rails to make background processing dead simple.
14
14
  Requirements
15
15
  -----------------
16
16
 
17
- - Redis: 6.2+
17
+ - Redis: Redis 6.2+ or Dragonfly 1.13+
18
18
  - Ruby: MRI 2.7+ or JRuby 9.3+.
19
19
 
20
20
  Sidekiq 7.0 supports Rails 6.0+ but does not require it.
21
-
21
+ As of 7.2, Sidekiq supports Dragonfly as an alternative to Redis for data storage.
22
22
 
23
23
  Installation
24
24
  -----------------
@@ -120,9 +120,12 @@ class Loader
120
120
  start = Time.now
121
121
  @iter.times do
122
122
  arr = Array.new(@count) { |idx| [idx] }
123
- #always prepends by queue:: that's why we pass 'q1, q2 etc' instead of `queue::q1`
123
+ # Sidekiq always prepends "queue:" to the queue name,
124
+ # that's why we pass 'q1', 'q2', etc instead of 'queue:q1'
124
125
  Sidekiq::Client.push_bulk("class" => LoadWorker, "args" => arr, "queue" => queue)
126
+ $stdout.write "."
125
127
  end
128
+ puts "Done"
126
129
  end
127
130
 
128
131
  def monitor_single(queue)
@@ -176,7 +179,7 @@ class Loader
176
179
  end
177
180
 
178
181
  def run(queues, queue, monitor_all_queues)
179
- #Sidekiq.logger.warn("Consuming from #{queue}")
182
+ Sidekiq.logger.warn("Consuming from #{queue}")
180
183
  if monitor_all_queues
181
184
  monitor_all(queues)
182
185
  else
@@ -216,50 +219,50 @@ end
216
219
 
217
220
  # We assign one queue to each sidekiq process
218
221
  def run(number_of_processes, total_queues)
219
- read_stream, write_stream = IO.pipe
222
+ read_stream, write_stream = IO.pipe
220
223
 
221
- queues = []
222
- (0..total_queues-1).each do |idx|
223
- queues.push("queue:q#{idx}")
224
- end
224
+ queues = []
225
+ (0..total_queues-1).each do |idx|
226
+ queues.push("queue:q#{idx}")
227
+ end
225
228
 
226
- Sidekiq.logger.info("Queues are: #{queues}")
229
+ Sidekiq.logger.info("Queues are: #{queues}")
227
230
 
228
- # Produce
229
- start = Time.now
230
- (0..total_queues-1).each do |idx|
231
- Process.fork do
232
- queue_num = "q#{idx}"
233
- setup(queue_num)
234
- end
231
+ # Produce
232
+ start = Time.now
233
+ (0..total_queues-1).each do |idx|
234
+ Process.fork do
235
+ queue_num = "q#{idx}"
236
+ setup(queue_num)
235
237
  end
238
+ end
236
239
 
237
- queue_sz = $iterations * $elements * total_queues
238
- Process.waitall
239
-
240
- ending = Time.now - start
241
- #Sidekiq.logger.info("Pushed #{queue_sz} in #{ending} secs")
242
-
243
- # Consume
244
- (0..number_of_processes-1).each do |idx|
245
- Process.fork do
246
- # First process only consumes from it's own queue but monitors all queues.
247
- # It works as a synchronization point. Once all processes finish
248
- # (that is, when all queues are emptied) it prints the the stats.
249
- if idx == 0
250
- queue = "q#{idx}"
251
- consume(queues, queue, true)
252
- else
253
- queue = "q#{idx % total_queues}"
254
- consume(queues, queue, false)
255
- end
240
+ queue_sz = $iterations * $elements * total_queues
241
+ Process.waitall
242
+
243
+ ending = Time.now - start
244
+ #Sidekiq.logger.info("Pushed #{queue_sz} in #{ending} secs")
245
+
246
+ # Consume
247
+ (0..number_of_processes-1).each do |idx|
248
+ Process.fork do
249
+ # First process only consumes from it's own queue but monitors all queues.
250
+ # It works as a synchronization point. Once all processes finish
251
+ # (that is, when all queues are emptied) it prints the the stats.
252
+ if idx == 0
253
+ queue = "q#{idx}"
254
+ consume(queues, queue, true)
255
+ else
256
+ queue = "q#{idx % total_queues}"
257
+ consume(queues, queue, false)
256
258
  end
257
259
  end
260
+ end
258
261
 
259
- Process.waitall
260
- write_stream.close
261
- results = read_stream.read
262
- read_stream.close
262
+ Process.waitall
263
+ write_stream.close
264
+ results = read_stream.read
265
+ read_stream.close
263
266
  end
264
267
 
265
268
  $total_processes = ENV["PROCESSES"] ? Integer(ENV["PROCESSES"]) : 8;
data/lib/sidekiq/api.rb CHANGED
@@ -773,7 +773,7 @@ module Sidekiq
773
773
  #
774
774
  class ScheduledSet < JobSet
775
775
  def initialize
776
- super "schedule"
776
+ super("schedule")
777
777
  end
778
778
  end
779
779
 
@@ -787,7 +787,7 @@ module Sidekiq
787
787
  #
788
788
  class RetrySet < JobSet
789
789
  def initialize
790
- super "retry"
790
+ super("retry")
791
791
  end
792
792
 
793
793
  # Enqueues all jobs pending within the retry set.
@@ -808,7 +808,7 @@ module Sidekiq
808
808
  #
809
809
  class DeadSet < JobSet
810
810
  def initialize
811
- super "dead"
811
+ super("dead")
812
812
  end
813
813
 
814
814
  # Add the given job to the Dead set.
data/lib/sidekiq/cli.rb CHANGED
@@ -38,7 +38,7 @@ module Sidekiq # :nodoc:
38
38
  # Code within this method is not tested because it alters
39
39
  # global process state irreversibly. PRs which improve the
40
40
  # test coverage of Sidekiq::CLI are welcomed.
41
- def run(boot_app: true)
41
+ def run(boot_app: true, warmup: true)
42
42
  boot_application if boot_app
43
43
 
44
44
  if environment == "development" && $stdout.tty? && @config.logger.formatter.is_a?(Sidekiq::Logger::Formatters::Pretty)
@@ -101,6 +101,8 @@ module Sidekiq # :nodoc:
101
101
  # Touch middleware so it isn't lazy loaded by multiple threads, #3043
102
102
  @config.server_middleware
103
103
 
104
+ ::Process.warmup if warmup && ::Process.respond_to?(:warmup)
105
+
104
106
  # Before this point, the process is initializing with just the main thread.
105
107
  # Starting here the process will now have multiple threads running.
106
108
  fire_event(:startup, reverse: false, reraise: true)
data/lib/sidekiq/job.rb CHANGED
@@ -109,7 +109,7 @@ module Sidekiq
109
109
  m = "#{name}="
110
110
  undef_method(m) if method_defined?(m) || private_method_defined?(m)
111
111
  end
112
- define_singleton_method("#{name}=") do |val|
112
+ define_singleton_method(:"#{name}=") do |val|
113
113
  singleton_class.class_eval do
114
114
  ACCESSOR_MUTEX.synchronize do
115
115
  undef_method(synchronized_getter) if method_defined?(synchronized_getter) || private_method_defined?(synchronized_getter)
@@ -36,7 +36,7 @@ module Sidekiq
36
36
  end
37
37
 
38
38
  LEVELS.each do |level, numeric_level|
39
- define_method("#{level}?") do
39
+ define_method(:"#{level}?") do
40
40
  local_level.nil? ? super() : local_level <= numeric_level
41
41
  end
42
42
  end
@@ -54,7 +54,7 @@ module Sidekiq
54
54
  cattrs_to_reset << constklass
55
55
 
56
56
  job[key].each do |(attribute, value)|
57
- constklass.public_send("#{attribute}=", value)
57
+ constklass.public_send(:"#{attribute}=", value)
58
58
  end
59
59
  end
60
60
  end
data/lib/sidekiq/rails.rb CHANGED
@@ -20,6 +20,10 @@ module Sidekiq
20
20
  def inspect
21
21
  "#<Sidekiq::Rails::Reloader @app=#{@app.class.name}>"
22
22
  end
23
+
24
+ def to_hash
25
+ { app: @app.class.name }
26
+ end
23
27
  end
24
28
 
25
29
  # By including the Options module, we allow AJs to directly control sidekiq features
@@ -66,9 +66,7 @@ module Sidekiq
66
66
  EOM
67
67
  end
68
68
 
69
- ENV[
70
- p || "REDIS_URL"
71
- ]
69
+ ENV[p.to_s] || ENV["REDIS_URL"]
72
70
  end
73
71
  end
74
72
  end
@@ -9,7 +9,14 @@ module Sidekiq
9
9
  @redis_client = Client.new(pool: pool, config: config)
10
10
  end
11
11
 
12
+ def batching?
13
+ Thread.current[:sidekiq_batch]
14
+ end
15
+
12
16
  def push(item)
17
+ # 6160 we can't support both Sidekiq::Batch and transactions.
18
+ return @redis_client.push(item) if batching?
19
+
13
20
  # pre-allocate the JID so we can return it immediately and
14
21
  # save it to the database as part of the transaction.
15
22
  item["jid"] ||= SecureRandom.hex(12)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sidekiq
4
- VERSION = "7.2.1"
4
+ VERSION = "7.2.2"
5
5
  MAJOR = 7
6
6
  end
@@ -56,7 +56,7 @@ module Sidekiq
56
56
  end
57
57
 
58
58
  def logger(env)
59
- @logger ||= (env["rack.logger"] || ::Logger.new(env["rack.errors"]))
59
+ @logger ||= env["rack.logger"] || ::Logger.new(env["rack.errors"])
60
60
  end
61
61
 
62
62
  def deny(env)
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: 7.2.1
4
+ version: 7.2.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: 2024-01-19 00:00:00.000000000 Z
11
+ date: 2024-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client