bullmq 5.44.1 → 5.44.2
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/commands/includes/moveParentToFailedIfNeeded.lua +82 -0
- package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.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 +3 -3
- package/dist/cjs/scripts/addDelayedJob-6.js +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js +1 -1
- package/dist/cjs/scripts/addStandardJob-8.js +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +61 -59
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +61 -59
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/moveToWaitingChildren-8.js +62 -60
- package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/commands/includes/moveParentToFailedIfNeeded.lua +82 -0
- package/dist/esm/commands/includes/moveParentToWaitIfNeeded.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 +3 -3
- package/dist/esm/scripts/addDelayedJob-6.js +1 -1
- package/dist/esm/scripts/addParentJob-4.js +1 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js +1 -1
- package/dist/esm/scripts/addStandardJob-8.js +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +61 -59
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +61 -59
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/moveToWaitingChildren-8.js +62 -60
- package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +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/moveParentFromWaitingChildrenToFailed.lua +0 -80
- package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -80
@@ -0,0 +1,82 @@
|
|
1
|
+
--[[
|
2
|
+
Function to recursively move from waitingChildren to failed.
|
3
|
+
]]
|
4
|
+
|
5
|
+
-- Includes
|
6
|
+
--- @include "moveParentToWaitIfNeeded"
|
7
|
+
--- @include "removeDeduplicationKeyIfNeeded"
|
8
|
+
--- @include "removeJobsOnFail"
|
9
|
+
|
10
|
+
local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
11
|
+
if rcall("EXISTS", parentKey) == 1 then
|
12
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
13
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
14
|
+
local parentPrioritizedKey = parentQueueKey .. ":prioritized"
|
15
|
+
local parentWaitingChildrenOrDelayedOrPrioritizedKey
|
16
|
+
local prevState
|
17
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
18
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentWaitingChildrenKey
|
19
|
+
prevState = "waiting-children"
|
20
|
+
elseif rcall("ZSCORE", parentDelayedKey, parentId) then
|
21
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentDelayedKey
|
22
|
+
prevState = "delayed"
|
23
|
+
elseif rcall("ZSCORE", parentPrioritizedKey, parentId) then
|
24
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentPrioritizedKey
|
25
|
+
prevState = "prioritized"
|
26
|
+
end
|
27
|
+
|
28
|
+
if parentWaitingChildrenOrDelayedOrPrioritizedKey then
|
29
|
+
rcall("ZREM", parentWaitingChildrenOrDelayedOrPrioritizedKey, parentId)
|
30
|
+
local parentQueuePrefix = parentQueueKey .. ":"
|
31
|
+
local parentFailedKey = parentQueueKey .. ":failed"
|
32
|
+
rcall("ZADD", parentFailedKey, timestamp, parentId)
|
33
|
+
local failedReason = "child " .. jobIdKey .. " failed"
|
34
|
+
rcall("HSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
|
35
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
|
36
|
+
failedReason, "prev", prevState)
|
37
|
+
|
38
|
+
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
|
39
|
+
|
40
|
+
removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
|
41
|
+
|
42
|
+
if jobAttributes[1] then
|
43
|
+
local parentData = cjson.decode(jobAttributes[1])
|
44
|
+
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
45
|
+
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
46
|
+
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
47
|
+
if parentData['fpof'] then
|
48
|
+
moveParentToFailedIfNeeded(
|
49
|
+
parentData['queueKey'],
|
50
|
+
parentData['queueKey'] .. ':' .. parentData['id'],
|
51
|
+
parentData['id'],
|
52
|
+
parentKey,
|
53
|
+
timestamp
|
54
|
+
)
|
55
|
+
elseif parentData['idof'] or parentData['rdof'] then
|
56
|
+
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
57
|
+
local grandParentDependenciesSet = grandParentKey .. ":dependencies"
|
58
|
+
if rcall("SREM", grandParentDependenciesSet, parentKey) == 1 then
|
59
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], grandParentDependenciesSet,
|
60
|
+
grandParentKey, parentData['id'], timestamp)
|
61
|
+
if parentData['idof'] then
|
62
|
+
local grandParentFailedSet = grandParentKey .. ":failed"
|
63
|
+
rcall("HSET", grandParentFailedSet, parentKey, failedReason)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
local parentRawOpts = jobAttributes[3]
|
70
|
+
local parentOpts = cjson.decode(parentRawOpts)
|
71
|
+
|
72
|
+
removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
|
73
|
+
else
|
74
|
+
local grandParentKey = rcall("HGET", parentKey, "parentKey")
|
75
|
+
|
76
|
+
if grandParentKey then
|
77
|
+
local grandParentUnsuccesssfulSet = grandParentKey .. ":unsuccessful"
|
78
|
+
rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -13,7 +13,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
13
13
|
parentKey, parentId, timestamp)
|
14
14
|
local isParentActive = rcall("ZSCORE",
|
15
15
|
parentQueueKey .. ":waiting-children", parentId)
|
16
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
16
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
17
17
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
18
18
|
local parentWaitKey = parentQueueKey .. ":wait"
|
19
19
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -27,7 +27,7 @@ local rcall = redis.call
|
|
27
27
|
--- @include "includes/addJobInTargetList"
|
28
28
|
--- @include "includes/batches"
|
29
29
|
--- @include "includes/getTargetQueueList"
|
30
|
-
--- @include "includes/
|
30
|
+
--- @include "includes/moveParentToFailedIfNeeded"
|
31
31
|
--- @include "includes/moveParentToWaitIfNeeded"
|
32
32
|
--- @include "includes/removeDeduplicationKeyIfNeeded"
|
33
33
|
--- @include "includes/removeJobsOnFail"
|
@@ -103,7 +103,7 @@ if (#stalling > 0) then
|
|
103
103
|
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
104
104
|
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
105
105
|
rcall("ZADD", unsuccesssfulSet, timestamp, jobKey)
|
106
|
-
|
106
|
+
moveParentToFailedIfNeeded(
|
107
107
|
parentData['queueKey'],
|
108
108
|
parentData['queueKey'] .. ':' .. parentData['id'],
|
109
109
|
parentData['id'],
|
@@ -63,7 +63,7 @@ local rcall = redis.call
|
|
63
63
|
--- @include "includes/getRateLimitTTL"
|
64
64
|
--- @include "includes/getTargetQueueList"
|
65
65
|
--- @include "includes/moveJobFromPriorityToActive"
|
66
|
-
--- @include "includes/
|
66
|
+
--- @include "includes/moveParentToFailedIfNeeded"
|
67
67
|
--- @include "includes/moveParentToWaitIfNeeded"
|
68
68
|
--- @include "includes/prepareJobForProcessing"
|
69
69
|
--- @include "includes/promoteDelayedJobs"
|
@@ -148,7 +148,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
148
148
|
if opts['fpof'] then
|
149
149
|
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
150
150
|
rcall("ZADD", unsuccesssfulSet, timestamp, jobIdKey)
|
151
|
-
|
151
|
+
moveParentToFailedIfNeeded(parentQueueKey, parentKey,
|
152
152
|
parentId, jobIdKey,
|
153
153
|
timestamp)
|
154
154
|
elseif opts['idof'] or opts['rdof'] then
|
@@ -36,13 +36,13 @@ local timestamp = ARGV[3]
|
|
36
36
|
local jobId = ARGV[4]
|
37
37
|
|
38
38
|
--- Includes
|
39
|
-
--- @include "includes/
|
39
|
+
--- @include "includes/moveParentToFailedIfNeeded"
|
40
40
|
--- @include "includes/moveParentToWaitIfNeeded"
|
41
41
|
--- @include "includes/removeDeduplicationKeyIfNeeded"
|
42
42
|
--- @include "includes/removeJobsOnFail"
|
43
43
|
--- @include "includes/removeLock"
|
44
44
|
|
45
|
-
local function moveToWaitingChildren
|
45
|
+
local function moveToWaitingChildren(activeKey, waitingChildrenKey, jobId,
|
46
46
|
timestamp)
|
47
47
|
local score = tonumber(timestamp)
|
48
48
|
|
@@ -80,7 +80,7 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
80
80
|
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
81
81
|
local parentUnsuccesssful = parentKey .. ":unsuccessful"
|
82
82
|
rcall("ZADD", parentUnsuccesssful, timestamp, jobKey)
|
83
|
-
|
83
|
+
moveParentToFailedIfNeeded(
|
84
84
|
parentData['queueKey'],
|
85
85
|
parentData['queueKey'] .. ':' .. parentData['id'],
|
86
86
|
parentData['id'],
|
@@ -238,7 +238,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
238
238
|
parentKey, parentId, timestamp)
|
239
239
|
local isParentActive = rcall("ZSCORE",
|
240
240
|
parentQueueKey .. ":waiting-children", parentId)
|
241
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
241
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
242
242
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
243
243
|
local parentWaitKey = parentQueueKey .. ":wait"
|
244
244
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -194,7 +194,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
194
194
|
parentKey, parentId, timestamp)
|
195
195
|
local isParentActive = rcall("ZSCORE",
|
196
196
|
parentQueueKey .. ":waiting-children", parentId)
|
197
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
197
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
198
198
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
199
199
|
local parentWaitKey = parentQueueKey .. ":wait"
|
200
200
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -231,7 +231,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
231
231
|
parentKey, parentId, timestamp)
|
232
232
|
local isParentActive = rcall("ZSCORE",
|
233
233
|
parentQueueKey .. ":waiting-children", parentId)
|
234
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
234
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
235
235
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
236
236
|
local parentWaitKey = parentQueueKey .. ":wait"
|
237
237
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -204,7 +204,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
204
204
|
parentKey, parentId, timestamp)
|
205
205
|
local isParentActive = rcall("ZSCORE",
|
206
206
|
parentQueueKey .. ":waiting-children", parentId)
|
207
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
207
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
208
208
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
209
209
|
local parentWaitKey = parentQueueKey .. ":wait"
|
210
210
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -143,7 +143,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
143
143
|
parentKey, parentId, timestamp)
|
144
144
|
local isParentActive = rcall("ZSCORE",
|
145
145
|
parentQueueKey .. ":waiting-children", parentId)
|
146
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
146
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
147
147
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
148
148
|
local parentWaitKey = parentQueueKey .. ":wait"
|
149
149
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -361,67 +361,69 @@ local function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestam
|
|
361
361
|
end
|
362
362
|
end
|
363
363
|
end
|
364
|
-
local function
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
395
|
-
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
396
|
-
if parentData['fpof'] then
|
397
|
-
moveParentFromWaitingChildrenToFailed(
|
398
|
-
parentData['queueKey'],
|
399
|
-
parentData['queueKey'] .. ':' .. parentData['id'],
|
400
|
-
parentData['id'],
|
401
|
-
parentKey,
|
402
|
-
timestamp
|
403
|
-
)
|
404
|
-
elseif parentData['idof'] or parentData['rdof'] then
|
364
|
+
local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
365
|
+
if rcall("EXISTS", parentKey) == 1 then
|
366
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
367
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
368
|
+
local parentPrioritizedKey = parentQueueKey .. ":prioritized"
|
369
|
+
local parentWaitingChildrenOrDelayedOrPrioritizedKey
|
370
|
+
local prevState
|
371
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
372
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentWaitingChildrenKey
|
373
|
+
prevState = "waiting-children"
|
374
|
+
elseif rcall("ZSCORE", parentDelayedKey, parentId) then
|
375
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentDelayedKey
|
376
|
+
prevState = "delayed"
|
377
|
+
elseif rcall("ZSCORE", parentPrioritizedKey, parentId) then
|
378
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentPrioritizedKey
|
379
|
+
prevState = "prioritized"
|
380
|
+
end
|
381
|
+
if parentWaitingChildrenOrDelayedOrPrioritizedKey then
|
382
|
+
rcall("ZREM", parentWaitingChildrenOrDelayedOrPrioritizedKey, parentId)
|
383
|
+
local parentQueuePrefix = parentQueueKey .. ":"
|
384
|
+
local parentFailedKey = parentQueueKey .. ":failed"
|
385
|
+
rcall("ZADD", parentFailedKey, timestamp, parentId)
|
386
|
+
local failedReason = "child " .. jobIdKey .. " failed"
|
387
|
+
rcall("HSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
|
388
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
|
389
|
+
failedReason, "prev", prevState)
|
390
|
+
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
|
391
|
+
removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
|
392
|
+
if jobAttributes[1] then
|
393
|
+
local parentData = cjson.decode(jobAttributes[1])
|
405
394
|
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
406
|
-
local
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
395
|
+
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
396
|
+
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
397
|
+
if parentData['fpof'] then
|
398
|
+
moveParentToFailedIfNeeded(
|
399
|
+
parentData['queueKey'],
|
400
|
+
parentData['queueKey'] .. ':' .. parentData['id'],
|
401
|
+
parentData['id'],
|
402
|
+
parentKey,
|
403
|
+
timestamp
|
404
|
+
)
|
405
|
+
elseif parentData['idof'] or parentData['rdof'] then
|
406
|
+
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
407
|
+
local grandParentDependenciesSet = grandParentKey .. ":dependencies"
|
408
|
+
if rcall("SREM", grandParentDependenciesSet, parentKey) == 1 then
|
409
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], grandParentDependenciesSet,
|
410
|
+
grandParentKey, parentData['id'], timestamp)
|
411
|
+
if parentData['idof'] then
|
412
|
+
local grandParentFailedSet = grandParentKey .. ":failed"
|
413
|
+
rcall("HSET", grandParentFailedSet, parentKey, failedReason)
|
414
|
+
end
|
413
415
|
end
|
414
416
|
end
|
415
417
|
end
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
418
|
+
local parentRawOpts = jobAttributes[3]
|
419
|
+
local parentOpts = cjson.decode(parentRawOpts)
|
420
|
+
removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
|
421
|
+
else
|
422
|
+
local grandParentKey = rcall("HGET", parentKey, "parentKey")
|
423
|
+
if grandParentKey then
|
424
|
+
local grandParentUnsuccesssfulSet = grandParentKey .. ":unsuccessful"
|
425
|
+
rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
|
426
|
+
end
|
425
427
|
end
|
426
428
|
end
|
427
429
|
end
|
@@ -509,7 +511,7 @@ if (#stalling > 0) then
|
|
509
511
|
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
510
512
|
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
511
513
|
rcall("ZADD", unsuccesssfulSet, timestamp, jobKey)
|
512
|
-
|
514
|
+
moveParentToFailedIfNeeded(
|
513
515
|
parentData['queueKey'],
|
514
516
|
parentData['queueKey'] .. ':' .. parentData['id'],
|
515
517
|
parentData['id'],
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA6iBS,CAAC;AACb,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -238,7 +238,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
238
238
|
parentKey, parentId, timestamp)
|
239
239
|
local isParentActive = rcall("ZSCORE",
|
240
240
|
parentQueueKey .. ":waiting-children", parentId)
|
241
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
241
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
242
242
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
243
243
|
local parentWaitKey = parentQueueKey .. ":wait"
|
244
244
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -456,67 +456,69 @@ local function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestam
|
|
456
456
|
end
|
457
457
|
end
|
458
458
|
end
|
459
|
-
local function
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
490
|
-
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
491
|
-
if parentData['fpof'] then
|
492
|
-
moveParentFromWaitingChildrenToFailed(
|
493
|
-
parentData['queueKey'],
|
494
|
-
parentData['queueKey'] .. ':' .. parentData['id'],
|
495
|
-
parentData['id'],
|
496
|
-
parentKey,
|
497
|
-
timestamp
|
498
|
-
)
|
499
|
-
elseif parentData['idof'] or parentData['rdof'] then
|
459
|
+
local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
460
|
+
if rcall("EXISTS", parentKey) == 1 then
|
461
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
462
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
463
|
+
local parentPrioritizedKey = parentQueueKey .. ":prioritized"
|
464
|
+
local parentWaitingChildrenOrDelayedOrPrioritizedKey
|
465
|
+
local prevState
|
466
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
467
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentWaitingChildrenKey
|
468
|
+
prevState = "waiting-children"
|
469
|
+
elseif rcall("ZSCORE", parentDelayedKey, parentId) then
|
470
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentDelayedKey
|
471
|
+
prevState = "delayed"
|
472
|
+
elseif rcall("ZSCORE", parentPrioritizedKey, parentId) then
|
473
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentPrioritizedKey
|
474
|
+
prevState = "prioritized"
|
475
|
+
end
|
476
|
+
if parentWaitingChildrenOrDelayedOrPrioritizedKey then
|
477
|
+
rcall("ZREM", parentWaitingChildrenOrDelayedOrPrioritizedKey, parentId)
|
478
|
+
local parentQueuePrefix = parentQueueKey .. ":"
|
479
|
+
local parentFailedKey = parentQueueKey .. ":failed"
|
480
|
+
rcall("ZADD", parentFailedKey, timestamp, parentId)
|
481
|
+
local failedReason = "child " .. jobIdKey .. " failed"
|
482
|
+
rcall("HSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
|
483
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
|
484
|
+
failedReason, "prev", prevState)
|
485
|
+
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
|
486
|
+
removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
|
487
|
+
if jobAttributes[1] then
|
488
|
+
local parentData = cjson.decode(jobAttributes[1])
|
500
489
|
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
501
|
-
local
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
490
|
+
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
491
|
+
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
492
|
+
if parentData['fpof'] then
|
493
|
+
moveParentToFailedIfNeeded(
|
494
|
+
parentData['queueKey'],
|
495
|
+
parentData['queueKey'] .. ':' .. parentData['id'],
|
496
|
+
parentData['id'],
|
497
|
+
parentKey,
|
498
|
+
timestamp
|
499
|
+
)
|
500
|
+
elseif parentData['idof'] or parentData['rdof'] then
|
501
|
+
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
502
|
+
local grandParentDependenciesSet = grandParentKey .. ":dependencies"
|
503
|
+
if rcall("SREM", grandParentDependenciesSet, parentKey) == 1 then
|
504
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], grandParentDependenciesSet,
|
505
|
+
grandParentKey, parentData['id'], timestamp)
|
506
|
+
if parentData['idof'] then
|
507
|
+
local grandParentFailedSet = grandParentKey .. ":failed"
|
508
|
+
rcall("HSET", grandParentFailedSet, parentKey, failedReason)
|
509
|
+
end
|
508
510
|
end
|
509
511
|
end
|
510
512
|
end
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
513
|
+
local parentRawOpts = jobAttributes[3]
|
514
|
+
local parentOpts = cjson.decode(parentRawOpts)
|
515
|
+
removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
|
516
|
+
else
|
517
|
+
local grandParentKey = rcall("HGET", parentKey, "parentKey")
|
518
|
+
if grandParentKey then
|
519
|
+
local grandParentUnsuccesssfulSet = grandParentKey .. ":unsuccessful"
|
520
|
+
rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
|
521
|
+
end
|
520
522
|
end
|
521
523
|
end
|
522
524
|
end
|
@@ -709,7 +711,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
709
711
|
if opts['fpof'] then
|
710
712
|
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
711
713
|
rcall("ZADD", unsuccesssfulSet, timestamp, jobIdKey)
|
712
|
-
|
714
|
+
moveParentToFailedIfNeeded(parentQueueKey, parentKey,
|
713
715
|
parentId, jobIdKey,
|
714
716
|
timestamp)
|
715
717
|
elseif opts['idof'] or opts['rdof'] then
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyzBf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|