Skip to content

Commit

Permalink
fix(repeatable): pass custom key as an args in addRepeatableJob to pr…
Browse files Browse the repository at this point in the history
…event CROSSSLOT issue (#2662) fixes #2660
  • Loading branch information
roggervalf authored Jul 18, 2024
1 parent 3e071fa commit 9d8f874
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/classes/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,13 @@ export class Scripts {
legacyCustomKey: string,
skipCheckExists: boolean,
): (string | number | Buffer)[] {
const keys: (string | number | Buffer)[] = [
this.queue.keys.repeat,
customKey,
];
const keys: (string | number | Buffer)[] = [this.queue.keys.repeat];

const args = [
nextMillis,
pack(opts),
legacyCustomKey,
customKey,
skipCheckExists ? '1' : '0',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Input:
KEYS[1] 'repeat' key
KEYS[2] custom key
ARGV[1] next milliseconds
ARGV[2] msgpacked options
Expand All @@ -13,16 +12,17 @@
[4] endDate?
[5] every?
ARGV[3] legacy custom key TODO: remove this logic in next breaking change
ARGV[4] skipCheckExists
ARGV[4] custom key
ARGV[5] skipCheckExists
Output:
repeatableKey - OK
]]
local rcall = redis.call
local repeatKey = KEYS[1]
local customKey = KEYS[2]
local legacyCustomKey = ARGV[3]
local nextMilli = ARGV[1]
local legacyCustomKey = ARGV[3]
local customKey = ARGV[4]

local function storeRepeatableJob(repeatKey, customKey, nextMilli, rawOpts)
rcall("ZADD", repeatKey, nextMilli, customKey)
Expand Down Expand Up @@ -55,7 +55,7 @@ local function storeRepeatableJob(repeatKey, customKey, nextMilli, rawOpts)
return customKey
end

if ARGV[4] == '0' then
if ARGV[5] == '0' then
if rcall("ZSCORE", repeatKey, legacyCustomKey) ~= false then
rcall("ZADD", repeatKey, nextMilli, legacyCustomKey)
return legacyCustomKey
Expand Down

0 comments on commit 9d8f874

Please sign in to comment.