Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(repeatable): pass custom key as an args in addRepeatableJob to prevent CROSSSLOT issue #2662

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading