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(scripts): remove from stalled after moving to wait or delayed #2731

Merged
merged 1 commit into from
May 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
KEYS[1] active key
KEYS[2] delayed key
KEYS[3] job key
KEYS[4] stalled key

ARGV[1] delayedTimestamp
ARGV[2] the id of the job
Expand All @@ -21,14 +22,13 @@
local rcall = redis.call

if rcall("EXISTS", KEYS[3]) == 1 then
local lockKey
local lock

-- Check for job lock
if ARGV[3] ~= "0" then
lockKey = KEYS[3] .. ':lock'
lock = rcall("GET", lockKey)
if lock ~= ARGV[3] then
local lockKey = KEYS[3] .. ':lock'
if rcall("GET", lockKey) == ARGV[3] then
rcall("DEL", lockKey)
rcall("SREM", KEYS[4], ARGV[2])
else
return -2
end
end
Expand All @@ -38,10 +38,6 @@ if rcall("EXISTS", KEYS[3]) == 1 then
rcall("PUBLISH", KEYS[2], (score / 0x1000))
rcall("LREM", KEYS[1], 0, ARGV[2])

if lock then
rcall("DEL", lockKey)
end

return 0
else
return -1
Expand Down
7 changes: 5 additions & 2 deletions lib/commands/retryJob-5.lua → lib/commands/retryJob-6.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
KEYS[3] jobId
KEYS[4] 'meta-paused'
KEYS[5] 'paused'
KEYS[6] stalled key

ARGV[1] pushCmd
ARGV[2] jobId
Expand All @@ -26,8 +27,10 @@ if rcall("EXISTS", KEYS[3]) == 1 then
-- Check for job lock
if ARGV[3] ~= "0" then
local lockKey = KEYS[3] .. ':lock'
local lock = rcall("GET", lockKey)
if lock ~= ARGV[3] then
if rcall("GET", lockKey) == ARGV[3] then
rcall("DEL", lockKey)
rcall("SREM", KEYS[6], ARGV[2])
else
return -2
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ const scripts = {
timestamp = timestamp * 0x1000 + (jobId & 0xfff);
}

const keys = _.map(['active', 'delayed', jobId], name => {
const keys = _.map(['active', 'delayed', jobId, 'stalled'], name => {
return queue.toKey(name);
});
return keys.concat([
Expand Down Expand Up @@ -462,7 +462,7 @@ const scripts = {
const jobId = job.id;

const keys = _.map(
['active', 'wait', jobId, 'meta-paused', 'paused'],
['active', 'wait', jobId, 'meta-paused', 'paused', 'stalled'],
name => {
return queue.toKey(name);
}
Expand Down
Loading