Skip to content

Commit 9d8f874

Browse files
authored
fix(repeatable): pass custom key as an args in addRepeatableJob to prevent CROSSSLOT issue (#2662) fixes #2660
1 parent 3e071fa commit 9d8f874

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/classes/scripts.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,13 @@ export class Scripts {
267267
legacyCustomKey: string,
268268
skipCheckExists: boolean,
269269
): (string | number | Buffer)[] {
270-
const keys: (string | number | Buffer)[] = [
271-
this.queue.keys.repeat,
272-
customKey,
273-
];
270+
const keys: (string | number | Buffer)[] = [this.queue.keys.repeat];
274271

275272
const args = [
276273
nextMillis,
277274
pack(opts),
278275
legacyCustomKey,
276+
customKey,
279277
skipCheckExists ? '1' : '0',
280278
];
281279

src/commands/addRepeatableJob-2.lua src/commands/addRepeatableJob-1.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
Input:
55
KEYS[1] 'repeat' key
6-
KEYS[2] custom key
76
87
ARGV[1] next milliseconds
98
ARGV[2] msgpacked options
@@ -13,16 +12,17 @@
1312
[4] endDate?
1413
[5] every?
1514
ARGV[3] legacy custom key TODO: remove this logic in next breaking change
16-
ARGV[4] skipCheckExists
15+
ARGV[4] custom key
16+
ARGV[5] skipCheckExists
1717
1818
Output:
1919
repeatableKey - OK
2020
]]
2121
local rcall = redis.call
2222
local repeatKey = KEYS[1]
23-
local customKey = KEYS[2]
24-
local legacyCustomKey = ARGV[3]
2523
local nextMilli = ARGV[1]
24+
local legacyCustomKey = ARGV[3]
25+
local customKey = ARGV[4]
2626

2727
local function storeRepeatableJob(repeatKey, customKey, nextMilli, rawOpts)
2828
rcall("ZADD", repeatKey, nextMilli, customKey)
@@ -55,7 +55,7 @@ local function storeRepeatableJob(repeatKey, customKey, nextMilli, rawOpts)
5555
return customKey
5656
end
5757

58-
if ARGV[4] == '0' then
58+
if ARGV[5] == '0' then
5959
if rcall("ZSCORE", repeatKey, legacyCustomKey) ~= false then
6060
rcall("ZADD", repeatKey, nextMilli, legacyCustomKey)
6161
return legacyCustomKey

0 commit comments

Comments
 (0)