bullmq 5.49.2 → 5.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/classes/flow-producer.js +7 -3
- package/dist/cjs/classes/flow-producer.js.map +1 -1
- package/dist/cjs/classes/job.js +80 -40
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/queue.js +0 -1
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/commands/addJobScheduler-11.lua +40 -45
- package/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +0 -1
- package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
- package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
- package/dist/cjs/commands/includes/removeJob.lua +2 -2
- package/dist/cjs/commands/includes/removeJobWithChildren.lua +2 -2
- package/dist/cjs/commands/includes/storeJob.lua +1 -1
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +2 -2
- package/dist/cjs/commands/moveToFinished-14.lua +2 -2
- package/dist/cjs/commands/moveToWaitingChildren-8.lua +2 -2
- package/dist/cjs/commands/updateJobScheduler-12.lua +1 -1
- package/dist/cjs/scripts/addDelayedJob-6.js +1 -1
- package/dist/cjs/scripts/addJobScheduler-11.js +44 -44
- package/dist/cjs/scripts/addParentJob-4.js +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js +1 -1
- package/dist/cjs/scripts/addRepeatableJob-2.js +9 -4
- package/dist/cjs/scripts/addRepeatableJob-2.js.map +1 -1
- package/dist/cjs/scripts/addStandardJob-8.js +1 -1
- package/dist/cjs/scripts/cleanJobsInSet-3.js +9 -4
- package/dist/cjs/scripts/cleanJobsInSet-3.js.map +1 -1
- package/dist/cjs/scripts/drain-5.js +9 -4
- package/dist/cjs/scripts/drain-5.js.map +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +30 -17
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +30 -17
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/moveToWaitingChildren-8.js +30 -17
- package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -1
- package/dist/cjs/scripts/obliterate-2.js +9 -4
- package/dist/cjs/scripts/obliterate-2.js.map +1 -1
- package/dist/cjs/scripts/removeJob-3.js +9 -4
- package/dist/cjs/scripts/removeJob-3.js.map +1 -1
- package/dist/cjs/scripts/removeUnprocessedChildren-2.js +9 -4
- package/dist/cjs/scripts/removeUnprocessedChildren-2.js.map +1 -1
- package/dist/cjs/scripts/updateJobScheduler-12.js +2 -2
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/utils.js +11 -1
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/flow-producer.js +7 -3
- package/dist/esm/classes/flow-producer.js.map +1 -1
- package/dist/esm/classes/job.d.ts +21 -6
- package/dist/esm/classes/job.js +81 -41
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/queue.d.ts +0 -1
- package/dist/esm/classes/queue.js +0 -1
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/commands/addJobScheduler-11.lua +40 -45
- package/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +0 -1
- package/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
- package/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
- package/dist/esm/commands/includes/removeJob.lua +2 -2
- package/dist/esm/commands/includes/removeJobWithChildren.lua +2 -2
- package/dist/esm/commands/includes/storeJob.lua +1 -1
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +2 -2
- package/dist/esm/commands/moveToFinished-14.lua +2 -2
- package/dist/esm/commands/moveToWaitingChildren-8.lua +2 -2
- package/dist/esm/commands/updateJobScheduler-12.lua +1 -1
- package/dist/esm/interfaces/minimal-job.d.ts +22 -8
- package/dist/esm/scripts/addDelayedJob-6.js +1 -1
- package/dist/esm/scripts/addJobScheduler-11.js +44 -44
- package/dist/esm/scripts/addParentJob-4.js +1 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js +1 -1
- package/dist/esm/scripts/addRepeatableJob-2.js +9 -4
- package/dist/esm/scripts/addRepeatableJob-2.js.map +1 -1
- package/dist/esm/scripts/addStandardJob-8.js +1 -1
- package/dist/esm/scripts/cleanJobsInSet-3.js +9 -4
- package/dist/esm/scripts/cleanJobsInSet-3.js.map +1 -1
- package/dist/esm/scripts/drain-5.js +9 -4
- package/dist/esm/scripts/drain-5.js.map +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +30 -17
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +30 -17
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/moveToWaitingChildren-8.js +30 -17
- package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -1
- package/dist/esm/scripts/obliterate-2.js +9 -4
- package/dist/esm/scripts/obliterate-2.js.map +1 -1
- package/dist/esm/scripts/removeJob-3.js +9 -4
- package/dist/esm/scripts/removeJob-3.js.map +1 -1
- package/dist/esm/scripts/removeUnprocessedChildren-2.js +9 -4
- package/dist/esm/scripts/removeUnprocessedChildren-2.js.map +1 -1
- package/dist/esm/scripts/updateJobScheduler-12.js +2 -2
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils.d.ts +17 -0
- package/dist/esm/utils.js +10 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/commands/includes/removeDeduplicationKey.lua +0 -11
- package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
- package/dist/esm/commands/includes/removeDeduplicationKey.lua +0 -11
- package/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
@@ -3,7 +3,7 @@
|
|
3
3
|
]]
|
4
4
|
|
5
5
|
-- Includes
|
6
|
-
--- @include "
|
6
|
+
--- @include "removeDeduplicationKeyIfNeededOnRemoval"
|
7
7
|
--- @include "removeJobKeys"
|
8
8
|
--- @include "removeParentDependencyKey"
|
9
9
|
|
@@ -11,7 +11,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
11
11
|
local jobKey = baseKey .. jobId
|
12
12
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
13
13
|
if shouldRemoveDeduplicationKey then
|
14
|
-
|
14
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
15
15
|
end
|
16
16
|
removeJobKeys(jobKey)
|
17
17
|
end
|
@@ -12,7 +12,7 @@ local rcall = redis.call
|
|
12
12
|
--- @include "destructureJobKey"
|
13
13
|
--- @include "getOrSetMaxEvents"
|
14
14
|
--- @include "isJobSchedulerJob"
|
15
|
-
--- @include "
|
15
|
+
--- @include "removeDeduplicationKeyIfNeededOnRemoval"
|
16
16
|
--- @include "removeJobFromAnyState"
|
17
17
|
--- @include "removeJobKeys"
|
18
18
|
--- @include "removeParentDependencyKey"
|
@@ -84,7 +84,7 @@ removeJobWithChildren = function(prefix, meta, jobId, parentKey, options)
|
|
84
84
|
end
|
85
85
|
|
86
86
|
local prev = removeJobFromAnyState(prefix, jobId)
|
87
|
-
|
87
|
+
removeDeduplicationKeyIfNeededOnRemoval(prefix, jobKey, jobId)
|
88
88
|
if removeJobKeys(jobKey) > 0 then
|
89
89
|
local maxEvents = getOrSetMaxEvents(meta)
|
90
90
|
rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
|
@@ -16,7 +16,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
16
16
|
table.insert(optionalValues, parentData)
|
17
17
|
end
|
18
18
|
|
19
|
-
if repeatJobKey
|
19
|
+
if repeatJobKey then
|
20
20
|
table.insert(optionalValues, "rjk")
|
21
21
|
table.insert(optionalValues, repeatJobKey)
|
22
22
|
end
|
@@ -27,7 +27,7 @@ local rcall = redis.call
|
|
27
27
|
--- @include "includes/batches"
|
28
28
|
--- @include "includes/getTargetQueueList"
|
29
29
|
--- @include "includes/moveChildFromDependenciesIfNeeded"
|
30
|
-
--- @include "includes/
|
30
|
+
--- @include "includes/removeDeduplicationKeyIfNeededOnFinalization"
|
31
31
|
--- @include "includes/removeJobsOnFail"
|
32
32
|
--- @include "includes/trimEvents"
|
33
33
|
|
@@ -84,7 +84,7 @@ if (#stalling > 0) then
|
|
84
84
|
local rawParentData = jobAttributes[2]
|
85
85
|
local opts = cjson.decode(rawOpts)
|
86
86
|
rcall("ZADD", failedKey, timestamp, jobId)
|
87
|
-
|
87
|
+
removeDeduplicationKeyIfNeededOnFinalization(queueKeyPrefix, jobAttributes[3], jobId)
|
88
88
|
|
89
89
|
local failedReason = "job stalled more than allowable limit"
|
90
90
|
rcall("HMSET", jobKey, "failedReason", failedReason, "finishedOn", timestamp)
|
@@ -67,7 +67,7 @@ local rcall = redis.call
|
|
67
67
|
--- @include "includes/moveChildFromDependenciesIfNeeded"
|
68
68
|
--- @include "includes/prepareJobForProcessing"
|
69
69
|
--- @include "includes/promoteDelayedJobs"
|
70
|
-
--- @include "includes/
|
70
|
+
--- @include "includes/removeDeduplicationKeyIfNeededOnFinalization"
|
71
71
|
--- @include "includes/removeJobKeys"
|
72
72
|
--- @include "includes/removeJobsByMaxAge"
|
73
73
|
--- @include "includes/removeJobsByMaxCount"
|
@@ -130,7 +130,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
130
130
|
|
131
131
|
local prefix = ARGV[7]
|
132
132
|
|
133
|
-
|
133
|
+
removeDeduplicationKeyIfNeededOnFinalization(prefix, jobAttributes[3], jobId)
|
134
134
|
|
135
135
|
-- If job has a parent we need to
|
136
136
|
-- 1) remove this job id from parents dependencies
|
@@ -37,7 +37,7 @@ local jobId = ARGV[4]
|
|
37
37
|
|
38
38
|
--- Includes
|
39
39
|
--- @include "includes/moveChildFromDependenciesIfNeeded"
|
40
|
-
--- @include "includes/
|
40
|
+
--- @include "includes/removeDeduplicationKeyIfNeededOnFinalization"
|
41
41
|
--- @include "includes/removeJobsOnFail"
|
42
42
|
--- @include "includes/removeLock"
|
43
43
|
|
@@ -61,7 +61,7 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
61
61
|
-- TODO: refactor this logic in an include later
|
62
62
|
local jobAttributes = rcall("HMGET", jobKey, "parent", "deid", "opts")
|
63
63
|
|
64
|
-
|
64
|
+
removeDeduplicationKeyIfNeededOnFinalization(ARGV[5], jobAttributes[2], jobId)
|
65
65
|
|
66
66
|
local failedReason = "children are failed"
|
67
67
|
rcall("ZADD", failedKey, timestamp, jobId)
|
@@ -49,7 +49,7 @@ local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
|
|
49
49
|
|
50
50
|
-- Validate that scheduler exists.
|
51
51
|
local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
52
|
-
if prevMillis
|
52
|
+
if prevMillis then
|
53
53
|
local currentDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
54
54
|
|
55
55
|
if producerId == currentDelayedJobId then
|
@@ -348,7 +348,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
348
348
|
table.insert(optionalValues, "parent")
|
349
349
|
table.insert(optionalValues, parentData)
|
350
350
|
end
|
351
|
-
if repeatJobKey
|
351
|
+
if repeatJobKey then
|
352
352
|
table.insert(optionalValues, "rjk")
|
353
353
|
table.insert(optionalValues, repeatJobKey)
|
354
354
|
end
|
@@ -161,7 +161,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
161
161
|
table.insert(optionalValues, "parent")
|
162
162
|
table.insert(optionalValues, parentData)
|
163
163
|
end
|
164
|
-
if repeatJobKey
|
164
|
+
if repeatJobKey then
|
165
165
|
table.insert(optionalValues, "rjk")
|
166
166
|
table.insert(optionalValues, repeatJobKey)
|
167
167
|
end
|
@@ -241,13 +241,18 @@ end
|
|
241
241
|
]]
|
242
242
|
-- Includes
|
243
243
|
--[[
|
244
|
-
Function to remove deduplication key
|
244
|
+
Function to remove deduplication key if needed
|
245
|
+
when a job is being removed.
|
245
246
|
]]
|
246
|
-
local function
|
247
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
248
|
+
jobKey, jobId)
|
247
249
|
local deduplicationId = rcall("HGET", jobKey, "deid")
|
248
250
|
if deduplicationId then
|
249
251
|
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
250
|
-
rcall(
|
252
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
253
|
+
if currentJobId and currentJobId == jobId then
|
254
|
+
return rcall("DEL", deduplicationKey)
|
255
|
+
end
|
251
256
|
end
|
252
257
|
end
|
253
258
|
--[[
|
@@ -349,7 +354,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
349
354
|
local jobKey = baseKey .. jobId
|
350
355
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
351
356
|
if shouldRemoveDeduplicationKey then
|
352
|
-
|
357
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
353
358
|
end
|
354
359
|
removeJobKeys(jobKey)
|
355
360
|
end
|
@@ -396,54 +401,49 @@ end
|
|
396
401
|
local schedulerKey = repeatKey .. ":" .. jobSchedulerId
|
397
402
|
local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
|
398
403
|
local nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis
|
404
|
+
local maxEvents = getOrSetMaxEvents(metaKey)
|
405
|
+
local function removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey, jobId,
|
406
|
+
metaKey, eventsKey)
|
407
|
+
if rcall("ZSCORE", delayedKey, jobId) then
|
408
|
+
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
409
|
+
rcall("ZREM", delayedKey, jobId)
|
410
|
+
return true
|
411
|
+
elseif rcall("ZSCORE", prioritizedKey, jobId) then
|
412
|
+
removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
|
413
|
+
rcall("ZREM", prioritizedKey, jobId)
|
414
|
+
return true
|
415
|
+
else
|
416
|
+
local pausedOrWaitKey = waitKey
|
417
|
+
if isQueuePaused(metaKey) then
|
418
|
+
pausedOrWaitKey = pausedKey
|
419
|
+
end
|
420
|
+
if rcall("LREM", pausedOrWaitKey, 1, jobId) > 0 then
|
421
|
+
removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
|
422
|
+
return true
|
423
|
+
end
|
424
|
+
end
|
425
|
+
return false
|
426
|
+
end
|
427
|
+
if rcall("EXISTS", nextDelayedJobKey) == 1 then
|
428
|
+
if not removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,
|
429
|
+
nextDelayedJobId, metaKey, eventsKey) then
|
430
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
431
|
+
"duplicated", "jobId", nextDelayedJobId)
|
432
|
+
return nextDelayedJobId .. "" -- convert to string
|
433
|
+
end
|
434
|
+
end
|
399
435
|
local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
400
|
-
if prevMillis
|
436
|
+
if prevMillis then
|
401
437
|
local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
402
438
|
local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis
|
403
|
-
if rcall("EXISTS", nextDelayedJobKey) == 1 then
|
404
|
-
if rcall("ZSCORE", delayedKey, nextDelayedJobId) ~= false then
|
405
|
-
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
406
|
-
rcall("ZREM", delayedKey, nextDelayedJobId)
|
407
|
-
elseif rcall("ZSCORE", prioritizedKey, nextDelayedJobId) ~= false then
|
408
|
-
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
409
|
-
rcall("ZREM", prioritizedKey, nextDelayedJobId)
|
410
|
-
else
|
411
|
-
local pausedOrWaitKey = waitKey
|
412
|
-
if isQueuePaused(metaKey) then
|
413
|
-
pausedOrWaitKey = pausedKey
|
414
|
-
end
|
415
|
-
if rcall("LREM", pausedOrWaitKey, 1, nextDelayedJobId) > 0 then
|
416
|
-
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
417
|
-
else
|
418
|
-
local maxEvents = getOrSetMaxEvents(metaKey)
|
419
|
-
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
420
|
-
"duplicated", "jobId", nextDelayedJobId)
|
421
|
-
return nextDelayedJobId .. "" -- convert to string
|
422
|
-
end
|
423
|
-
end
|
424
|
-
end
|
425
439
|
if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then
|
426
|
-
|
427
|
-
|
428
|
-
rcall("ZREM", delayedKey, currentJobId)
|
429
|
-
elseif rcall("ZSCORE", prioritizedKey, currentJobId) ~= false then
|
430
|
-
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
431
|
-
rcall("ZREM", prioritizedKey, currentJobId)
|
432
|
-
else
|
433
|
-
local pausedOrWaitKey = waitKey
|
434
|
-
if isQueuePaused(metaKey) then
|
435
|
-
pausedOrWaitKey = pausedKey
|
436
|
-
end
|
437
|
-
if rcall("LREM", pausedOrWaitKey, 1, currentJobId) > 0 then
|
438
|
-
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
439
|
-
end
|
440
|
-
end
|
440
|
+
removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,
|
441
|
+
currentJobId, metaKey, eventsKey)
|
441
442
|
end
|
442
443
|
end
|
443
444
|
local schedulerOpts = cmsgpack.unpack(ARGV[2])
|
444
445
|
storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)
|
445
446
|
rcall("INCR", KEYS[8])
|
446
|
-
local maxEvents = getOrSetMaxEvents(metaKey)
|
447
447
|
addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
|
448
448
|
KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
|
449
449
|
schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
|
@@ -304,7 +304,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
304
304
|
table.insert(optionalValues, "parent")
|
305
305
|
table.insert(optionalValues, parentData)
|
306
306
|
end
|
307
|
-
if repeatJobKey
|
307
|
+
if repeatJobKey then
|
308
308
|
table.insert(optionalValues, "rjk")
|
309
309
|
table.insert(optionalValues, repeatJobKey)
|
310
310
|
end
|
@@ -115,7 +115,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
115
115
|
table.insert(optionalValues, "parent")
|
116
116
|
table.insert(optionalValues, parentData)
|
117
117
|
end
|
118
|
-
if repeatJobKey
|
118
|
+
if repeatJobKey then
|
119
119
|
table.insert(optionalValues, "rjk")
|
120
120
|
table.insert(optionalValues, repeatJobKey)
|
121
121
|
end
|
@@ -32,13 +32,18 @@ local prefixKey = ARGV[5]
|
|
32
32
|
]]
|
33
33
|
-- Includes
|
34
34
|
--[[
|
35
|
-
Function to remove deduplication key
|
35
|
+
Function to remove deduplication key if needed
|
36
|
+
when a job is being removed.
|
36
37
|
]]
|
37
|
-
local function
|
38
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
39
|
+
jobKey, jobId)
|
38
40
|
local deduplicationId = rcall("HGET", jobKey, "deid")
|
39
41
|
if deduplicationId then
|
40
42
|
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
41
|
-
rcall(
|
43
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
44
|
+
if currentJobId and currentJobId == jobId then
|
45
|
+
return rcall("DEL", deduplicationKey)
|
46
|
+
end
|
42
47
|
end
|
43
48
|
end
|
44
49
|
--[[
|
@@ -176,7 +181,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
176
181
|
local jobKey = baseKey .. jobId
|
177
182
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
178
183
|
if shouldRemoveDeduplicationKey then
|
179
|
-
|
184
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
180
185
|
end
|
181
186
|
removeJobKeys(jobKey)
|
182
187
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addRepeatableJob-2.js","sourceRoot":"","sources":["../../../src/scripts/addRepeatableJob-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addRepeatableJob-2.js","sourceRoot":"","sources":["../../../src/scripts/addRepeatableJob-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiOf,CAAC;AACW,QAAA,gBAAgB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -314,7 +314,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
314
314
|
table.insert(optionalValues, "parent")
|
315
315
|
table.insert(optionalValues, parentData)
|
316
316
|
end
|
317
|
-
if repeatJobKey
|
317
|
+
if repeatJobKey then
|
318
318
|
table.insert(optionalValues, "rjk")
|
319
319
|
table.insert(optionalValues, repeatJobKey)
|
320
320
|
end
|
@@ -68,13 +68,18 @@ end
|
|
68
68
|
]]
|
69
69
|
-- Includes
|
70
70
|
--[[
|
71
|
-
Function to remove deduplication key
|
71
|
+
Function to remove deduplication key if needed
|
72
|
+
when a job is being removed.
|
72
73
|
]]
|
73
|
-
local function
|
74
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
75
|
+
jobKey, jobId)
|
74
76
|
local deduplicationId = rcall("HGET", jobKey, "deid")
|
75
77
|
if deduplicationId then
|
76
78
|
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
77
|
-
rcall(
|
79
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
80
|
+
if currentJobId and currentJobId == jobId then
|
81
|
+
return rcall("DEL", deduplicationKey)
|
82
|
+
end
|
78
83
|
end
|
79
84
|
end
|
80
85
|
--[[
|
@@ -212,7 +217,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
212
217
|
local jobKey = baseKey .. jobId
|
213
218
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
214
219
|
if shouldRemoveDeduplicationKey then
|
215
|
-
|
220
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
216
221
|
end
|
217
222
|
removeJobKeys(jobKey)
|
218
223
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cleanJobsInSet-3.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-3.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"cleanJobsInSet-3.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-3.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoWf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -40,13 +40,18 @@ end
|
|
40
40
|
]]
|
41
41
|
-- Includes
|
42
42
|
--[[
|
43
|
-
Function to remove deduplication key
|
43
|
+
Function to remove deduplication key if needed
|
44
|
+
when a job is being removed.
|
44
45
|
]]
|
45
|
-
local function
|
46
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
47
|
+
jobKey, jobId)
|
46
48
|
local deduplicationId = rcall("HGET", jobKey, "deid")
|
47
49
|
if deduplicationId then
|
48
50
|
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
49
|
-
rcall(
|
51
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
52
|
+
if currentJobId and currentJobId == jobId then
|
53
|
+
return rcall("DEL", deduplicationKey)
|
54
|
+
end
|
50
55
|
end
|
51
56
|
end
|
52
57
|
--[[
|
@@ -184,7 +189,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
184
189
|
local jobKey = baseKey .. jobId
|
185
190
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
186
191
|
if shouldRemoveDeduplicationKey then
|
187
|
-
|
192
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
188
193
|
end
|
189
194
|
removeJobKeys(jobKey)
|
190
195
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"drain-5.js","sourceRoot":"","sources":["../../../src/scripts/drain-5.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"drain-5.js","sourceRoot":"","sources":["../../../src/scripts/drain-5.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsQf,CAAC;AACW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -197,18 +197,6 @@ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDep
|
|
197
197
|
moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
198
198
|
end
|
199
199
|
end
|
200
|
-
--[[
|
201
|
-
Function to remove deduplication key if needed.
|
202
|
-
]]
|
203
|
-
local function removeDeduplicationKeyIfNeeded(prefixKey, deduplicationId)
|
204
|
-
if deduplicationId then
|
205
|
-
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
206
|
-
local pttl = rcall("PTTL", deduplicationKey)
|
207
|
-
if pttl == 0 or pttl == -1 then
|
208
|
-
rcall("DEL", deduplicationKey)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
200
|
--[[
|
213
201
|
Functions to remove jobs when removeOnFail option is provided.
|
214
202
|
]]
|
@@ -218,13 +206,18 @@ end
|
|
218
206
|
]]
|
219
207
|
-- Includes
|
220
208
|
--[[
|
221
|
-
Function to remove deduplication key
|
209
|
+
Function to remove deduplication key if needed
|
210
|
+
when a job is being removed.
|
222
211
|
]]
|
223
|
-
local function
|
212
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
213
|
+
jobKey, jobId)
|
224
214
|
local deduplicationId = rcall("HGET", jobKey, "deid")
|
225
215
|
if deduplicationId then
|
226
216
|
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
227
|
-
rcall(
|
217
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
218
|
+
if currentJobId and currentJobId == jobId then
|
219
|
+
return rcall("DEL", deduplicationKey)
|
220
|
+
end
|
228
221
|
end
|
229
222
|
end
|
230
223
|
--[[
|
@@ -326,7 +319,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
326
319
|
local jobKey = baseKey .. jobId
|
327
320
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
328
321
|
if shouldRemoveDeduplicationKey then
|
329
|
-
|
322
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
330
323
|
end
|
331
324
|
removeJobKeys(jobKey)
|
332
325
|
end
|
@@ -446,6 +439,26 @@ moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedRea
|
|
446
439
|
end
|
447
440
|
end
|
448
441
|
end
|
442
|
+
--[[
|
443
|
+
Function to remove deduplication key if needed
|
444
|
+
when a job is moved to completed or failed states.
|
445
|
+
]]
|
446
|
+
local function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,
|
447
|
+
deduplicationId, jobId)
|
448
|
+
if deduplicationId then
|
449
|
+
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
450
|
+
local pttl = rcall("PTTL", deduplicationKey)
|
451
|
+
if pttl == 0 then
|
452
|
+
return rcall("DEL", deduplicationKey)
|
453
|
+
end
|
454
|
+
if pttl == -1 then
|
455
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
456
|
+
if currentJobId and currentJobId == jobId then
|
457
|
+
return rcall("DEL", deduplicationKey)
|
458
|
+
end
|
459
|
+
end
|
460
|
+
end
|
461
|
+
end
|
449
462
|
--[[
|
450
463
|
Function to trim events, default 10000.
|
451
464
|
]]
|
@@ -515,7 +528,7 @@ if (#stalling > 0) then
|
|
515
528
|
local rawParentData = jobAttributes[2]
|
516
529
|
local opts = cjson.decode(rawOpts)
|
517
530
|
rcall("ZADD", failedKey, timestamp, jobId)
|
518
|
-
|
531
|
+
removeDeduplicationKeyIfNeededOnFinalization(queueKeyPrefix, jobAttributes[3], jobId)
|
519
532
|
local failedReason = "job stalled more than allowable limit"
|
520
533
|
rcall("HMSET", jobKey, "failedReason", failedReason, "finishedOn", timestamp)
|
521
534
|
rcall("XADD", eventStreamKey, "*", "event", "failed", "jobId", jobId, 'prev', 'active',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6iBf,CAAC;AACW,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -293,18 +293,6 @@ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDep
|
|
293
293
|
moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
294
294
|
end
|
295
295
|
end
|
296
|
-
--[[
|
297
|
-
Function to remove deduplication key if needed.
|
298
|
-
]]
|
299
|
-
local function removeDeduplicationKeyIfNeeded(prefixKey, deduplicationId)
|
300
|
-
if deduplicationId then
|
301
|
-
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
302
|
-
local pttl = rcall("PTTL", deduplicationKey)
|
303
|
-
if pttl == 0 or pttl == -1 then
|
304
|
-
rcall("DEL", deduplicationKey)
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
308
296
|
--[[
|
309
297
|
Functions to remove jobs when removeOnFail option is provided.
|
310
298
|
]]
|
@@ -314,13 +302,18 @@ end
|
|
314
302
|
]]
|
315
303
|
-- Includes
|
316
304
|
--[[
|
317
|
-
Function to remove deduplication key
|
305
|
+
Function to remove deduplication key if needed
|
306
|
+
when a job is being removed.
|
318
307
|
]]
|
319
|
-
local function
|
308
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
309
|
+
jobKey, jobId)
|
320
310
|
local deduplicationId = rcall("HGET", jobKey, "deid")
|
321
311
|
if deduplicationId then
|
322
312
|
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
323
|
-
rcall(
|
313
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
314
|
+
if currentJobId and currentJobId == jobId then
|
315
|
+
return rcall("DEL", deduplicationKey)
|
316
|
+
end
|
324
317
|
end
|
325
318
|
end
|
326
319
|
--[[
|
@@ -422,7 +415,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
422
415
|
local jobKey = baseKey .. jobId
|
423
416
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
424
417
|
if shouldRemoveDeduplicationKey then
|
425
|
-
|
418
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
426
419
|
end
|
427
420
|
removeJobKeys(jobKey)
|
428
421
|
end
|
@@ -611,6 +604,26 @@ local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedK
|
|
611
604
|
addBaseMarkerIfNeeded(markerKey, isPaused)
|
612
605
|
end
|
613
606
|
end
|
607
|
+
--[[
|
608
|
+
Function to remove deduplication key if needed
|
609
|
+
when a job is moved to completed or failed states.
|
610
|
+
]]
|
611
|
+
local function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,
|
612
|
+
deduplicationId, jobId)
|
613
|
+
if deduplicationId then
|
614
|
+
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
615
|
+
local pttl = rcall("PTTL", deduplicationKey)
|
616
|
+
if pttl == 0 then
|
617
|
+
return rcall("DEL", deduplicationKey)
|
618
|
+
end
|
619
|
+
if pttl == -1 then
|
620
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
621
|
+
if currentJobId and currentJobId == jobId then
|
622
|
+
return rcall("DEL", deduplicationKey)
|
623
|
+
end
|
624
|
+
end
|
625
|
+
end
|
626
|
+
end
|
614
627
|
local function removeLock(jobKey, stalledKey, token, jobId)
|
615
628
|
if token ~= "0" then
|
616
629
|
local lockKey = jobKey .. ':lock'
|
@@ -715,7 +728,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
715
728
|
-- Trim events before emiting them to avoid trimming events emitted in this script
|
716
729
|
trimEvents(metaKey, eventStreamKey)
|
717
730
|
local prefix = ARGV[7]
|
718
|
-
|
731
|
+
removeDeduplicationKeyIfNeededOnFinalization(prefix, jobAttributes[3], jobId)
|
719
732
|
-- If job has a parent we need to
|
720
733
|
-- 1) remove this job id from parents dependencies
|
721
734
|
-- 2) move the job Id to parent "processed" set
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAi1Bf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|