Skip to content

Commit 1aca434

Browse files
committed
Remove deprecated command usage, fixes #5788
1 parent 0b753ff commit 1aca434

12 files changed

Lines changed: 52 additions & 26 deletions

Changes.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
[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)
44

5+
7.1.0
6+
----------
7+
8+
- Change return value of `push_bulk` to map 1-to-1 with arguments.
9+
If you call `push_bulk(args: [[1], [2], [3]])`, you will now always get
10+
an array of 3 values as the result: `["jid1", nil, "jid3"]` where nil means
11+
that particular job did not push successfully (possibly due to middleware
12+
stopping it). Previously nil values were removed so it was impossible to tell
13+
which jobs pushed successfully and which did not.
14+
- Migrate away from all deprecated Redis commands including `rpoplpush zrangebyscore zrevrange zrevrangebyscore getset hmset setex setnx`.
15+
516
7.0.5
617
----------
718

Ent-Changes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
Please see [sidekiq.org](https://sidekiq.org) for more details and how to buy.
66

7+
HEAD
8+
---------
9+
10+
- Add new points-based rate limiter popular with GraphQL endpoints at Shopify, GitHub, et al.
11+
Thanks to Thad Sauter of NexHealth for contributing the initial skeleton. [#5757]
12+
713
7.0.4
814
---------
915

Pro-Changes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
Please see [sidekiq.org](https://sidekiq.org/) for more details and how to buy.
66

7+
7.1.0
8+
---------
9+
10+
- **SEMANTIC CHANGE**: Empty batches now automatically create an empty job.
11+
This ensures callbacks are fired even if no jobs are created. The behavior
12+
of empty batches has always been documented as undefined so this is not
13+
considered a breaking change.
14+
715
7.0.7
816
---------
917

lib/sidekiq/api.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ def error?
548548
def remove_job
549549
Sidekiq.redis do |conn|
550550
results = conn.multi { |transaction|
551-
transaction.zrangebyscore(parent.name, score, score)
551+
transaction.zrange(parent.name, score, score, "BYSCORE")
552552
transaction.zremrangebyscore(parent.name, score, score)
553553
}.first
554554

@@ -683,7 +683,7 @@ def fetch(score, jid = nil)
683683
end
684684

685685
elements = Sidekiq.redis { |conn|
686-
conn.zrangebyscore(name, begin_score, end_score, withscores: true)
686+
conn.zrange(name, begin_score, end_score, "BYSCORE", withscores: true)
687687
}
688688

689689
elements.each_with_object([]) do |element, result|
@@ -724,7 +724,7 @@ def delete_by_value(name, value)
724724
# @api private
725725
def delete_by_jid(score, jid)
726726
Sidekiq.redis do |conn|
727-
elements = conn.zrangebyscore(name, score, score)
727+
elements = conn.zrange(name, score, score, "BYSCORE")
728728
elements.each do |element|
729729
if element.index(jid)
730730
message = Sidekiq.load_json(element)

lib/sidekiq/launcher.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def ❤
165165
conn.multi { |transaction|
166166
transaction.sadd("processes", [key])
167167
transaction.exists(key)
168-
transaction.hmset(key, "info", to_json,
168+
transaction.hset(key, "info", to_json,
169169
"busy", curstate.size,
170170
"beat", Time.now.to_f,
171171
"rtt_us", rtt,

lib/sidekiq/paginator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def page(key, pageidx = 1, page_size = 25, opts = nil)
1919
total_size, items = conn.multi { |transaction|
2020
transaction.zcard(key)
2121
if rev
22-
transaction.zrevrange(key, starting, ending, withscores: true)
22+
transaction.zrange(key, starting, ending, "REV", withscores: true)
2323
else
2424
transaction.zrange(key, starting, ending, withscores: true)
2525
end

lib/sidekiq/redis_client_adapter.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@ class RedisClientAdapter
99
CommandError = RedisClient::CommandError
1010

1111
module CompatMethods
12-
# TODO Deprecate and remove this
1312
def info
1413
@client.call("INFO") { |i| i.lines(chomp: true).map { |l| l.split(":", 2) }.select { |l| l.size == 2 }.to_h }
1514
end
1615

17-
# TODO Deprecate and remove this
1816
def evalsha(sha, keys, argv)
1917
@client.call("EVALSHA", sha, keys.size, *keys, *argv)
2018
end
2119

2220
private
2321

22+
DEPRECATED_COMMANDS = %i[rpoplpush zrangebyscore zrevrange zrevrangebyscore getset hmset setex setnx]
23+
2424
# this allows us to use methods like `conn.hmset(...)` instead of having to use
2525
# redis-client's native `conn.call("hmset", ...)`
2626
def method_missing(*args, &block)
27+
warn("Deprecated Redis command: #{args.first} at #{caller(1..1)}") if DEPRECATED_COMMANDS.include?(args.first)
2728
@client.call(*args, *block)
2829
end
2930
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)

lib/sidekiq/scheduled.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Enq
1212

1313
LUA_ZPOPBYSCORE = <<~LUA
1414
local key, now = KEYS[1], ARGV[1]
15-
local jobs = redis.call("zrangebyscore", key, "-inf", now, "limit", 0, 1)
15+
local jobs = redis.call("zrange", key, "-inf", now, "byscore", "limit", 0, 1)
1616
if jobs[1] then
1717
redis.call("zrem", key, jobs[1])
1818
return jobs[1]

lib/sidekiq/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

33
module Sidekiq
4-
VERSION = "7.0.5"
4+
VERSION = "7.1.0"
55
MAJOR = 7
66
end

test/api_test.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ class JobWithTags
541541
@cfg.redis do |conn|
542542
conn.multi do |transaction|
543543
transaction.sadd("processes", [odata["key"]])
544-
transaction.hmset(odata["key"], "info", Sidekiq.dump_json(odata), "busy", 10, "beat", time)
544+
transaction.hset(odata["key"], "info", Sidekiq.dump_json(odata), "busy", 10, "beat", time)
545545
transaction.sadd("processes", ["fake:pid"])
546546
end
547547
end
@@ -581,7 +581,7 @@ class JobWithTags
581581
@cfg.redis do |conn|
582582
conn.multi do |transaction|
583583
transaction.sadd("processes", [odata["key"]])
584-
transaction.hmset(odata["key"], "info", Sidekiq.dump_json(odata), "busy", 10, "beat", time)
584+
transaction.hset(odata["key"], "info", Sidekiq.dump_json(odata), "busy", 10, "beat", time)
585585
end
586586
end
587587

@@ -619,13 +619,13 @@ class JobWithTags
619619
pdata = {"pid" => $$, "hostname" => hn, "started_at" => Time.now.to_i}
620620
@cfg.redis do |conn|
621621
conn.sadd("processes", [key])
622-
conn.hmset(key, "info", Sidekiq.dump_json(pdata), "busy", 0, "beat", Time.now.to_f)
622+
conn.hset(key, "info", Sidekiq.dump_json(pdata), "busy", 0, "beat", Time.now.to_f)
623623
end
624624

625625
s = "#{key}:work"
626626
data = Sidekiq.dump_json({"payload" => "{}", "queue" => "default", "run_at" => Time.now.to_i})
627627
@cfg.redis do |c|
628-
c.hmset(s, "1234", data)
628+
c.hset(s, "1234", data)
629629
end
630630

631631
w.each do |p, x, y|
@@ -640,8 +640,8 @@ class JobWithTags
640640
data = Sidekiq.dump_json({"payload" => {}, "queue" => "default", "run_at" => (Time.now.to_i - 2 * 60 * 60)})
641641
@cfg.redis do |c|
642642
c.multi do |transaction|
643-
transaction.hmset(s, "5678", data)
644-
transaction.hmset("b#{s}", "5678", data)
643+
transaction.hset(s, "5678", data)
644+
transaction.hset("b#{s}", "5678", data)
645645
end
646646
end
647647

@@ -671,7 +671,7 @@ class JobWithTags
671671
key = "#{data["hostname"]}:#{data["pid"]}"
672672
@cfg.redis do |conn|
673673
conn.sadd("processes", [key])
674-
conn.hmset(key, "info", Sidekiq.dump_json(data), "busy", 0, "beat", Time.now.to_f)
674+
conn.hset(key, "info", Sidekiq.dump_json(data), "busy", 0, "beat", Time.now.to_f)
675675
end
676676
ps = Sidekiq::ProcessSet.new
677677
assert_equal 1, ps.size

0 commit comments

Comments
 (0)