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
@@ -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'],
|
@@ -235,7 +235,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
235
235
|
parentKey, parentId, timestamp)
|
236
236
|
local isParentActive = rcall("ZSCORE",
|
237
237
|
parentQueueKey .. ":waiting-children", parentId)
|
238
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
238
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
239
239
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
240
240
|
local parentWaitKey = parentQueueKey .. ":wait"
|
241
241
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -191,7 +191,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
191
191
|
parentKey, parentId, timestamp)
|
192
192
|
local isParentActive = rcall("ZSCORE",
|
193
193
|
parentQueueKey .. ":waiting-children", parentId)
|
194
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
194
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
195
195
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
196
196
|
local parentWaitKey = parentQueueKey .. ":wait"
|
197
197
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -228,7 +228,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
228
228
|
parentKey, parentId, timestamp)
|
229
229
|
local isParentActive = rcall("ZSCORE",
|
230
230
|
parentQueueKey .. ":waiting-children", parentId)
|
231
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
231
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
232
232
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
233
233
|
local parentWaitKey = parentQueueKey .. ":wait"
|
234
234
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -201,7 +201,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
201
201
|
parentKey, parentId, timestamp)
|
202
202
|
local isParentActive = rcall("ZSCORE",
|
203
203
|
parentQueueKey .. ":waiting-children", parentId)
|
204
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
204
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
205
205
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
206
206
|
local parentWaitKey = parentQueueKey .. ":wait"
|
207
207
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -140,7 +140,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
140
140
|
parentKey, parentId, timestamp)
|
141
141
|
local isParentActive = rcall("ZSCORE",
|
142
142
|
parentQueueKey .. ":waiting-children", parentId)
|
143
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
143
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
144
144
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
145
145
|
local parentWaitKey = parentQueueKey .. ":wait"
|
146
146
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -358,67 +358,69 @@ local function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestam
|
|
358
358
|
end
|
359
359
|
end
|
360
360
|
end
|
361
|
-
local function
|
362
|
-
|
363
|
-
|
364
|
-
|
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
|
-
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
392
|
-
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
393
|
-
if parentData['fpof'] then
|
394
|
-
moveParentFromWaitingChildrenToFailed(
|
395
|
-
parentData['queueKey'],
|
396
|
-
parentData['queueKey'] .. ':' .. parentData['id'],
|
397
|
-
parentData['id'],
|
398
|
-
parentKey,
|
399
|
-
timestamp
|
400
|
-
)
|
401
|
-
elseif parentData['idof'] or parentData['rdof'] then
|
361
|
+
local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
362
|
+
if rcall("EXISTS", parentKey) == 1 then
|
363
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
364
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
365
|
+
local parentPrioritizedKey = parentQueueKey .. ":prioritized"
|
366
|
+
local parentWaitingChildrenOrDelayedOrPrioritizedKey
|
367
|
+
local prevState
|
368
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
369
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentWaitingChildrenKey
|
370
|
+
prevState = "waiting-children"
|
371
|
+
elseif rcall("ZSCORE", parentDelayedKey, parentId) then
|
372
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentDelayedKey
|
373
|
+
prevState = "delayed"
|
374
|
+
elseif rcall("ZSCORE", parentPrioritizedKey, parentId) then
|
375
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentPrioritizedKey
|
376
|
+
prevState = "prioritized"
|
377
|
+
end
|
378
|
+
if parentWaitingChildrenOrDelayedOrPrioritizedKey then
|
379
|
+
rcall("ZREM", parentWaitingChildrenOrDelayedOrPrioritizedKey, parentId)
|
380
|
+
local parentQueuePrefix = parentQueueKey .. ":"
|
381
|
+
local parentFailedKey = parentQueueKey .. ":failed"
|
382
|
+
rcall("ZADD", parentFailedKey, timestamp, parentId)
|
383
|
+
local failedReason = "child " .. jobIdKey .. " failed"
|
384
|
+
rcall("HSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
|
385
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
|
386
|
+
failedReason, "prev", prevState)
|
387
|
+
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
|
388
|
+
removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
|
389
|
+
if jobAttributes[1] then
|
390
|
+
local parentData = cjson.decode(jobAttributes[1])
|
402
391
|
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
403
|
-
local
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
392
|
+
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
393
|
+
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
394
|
+
if parentData['fpof'] then
|
395
|
+
moveParentToFailedIfNeeded(
|
396
|
+
parentData['queueKey'],
|
397
|
+
parentData['queueKey'] .. ':' .. parentData['id'],
|
398
|
+
parentData['id'],
|
399
|
+
parentKey,
|
400
|
+
timestamp
|
401
|
+
)
|
402
|
+
elseif parentData['idof'] or parentData['rdof'] then
|
403
|
+
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
404
|
+
local grandParentDependenciesSet = grandParentKey .. ":dependencies"
|
405
|
+
if rcall("SREM", grandParentDependenciesSet, parentKey) == 1 then
|
406
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], grandParentDependenciesSet,
|
407
|
+
grandParentKey, parentData['id'], timestamp)
|
408
|
+
if parentData['idof'] then
|
409
|
+
local grandParentFailedSet = grandParentKey .. ":failed"
|
410
|
+
rcall("HSET", grandParentFailedSet, parentKey, failedReason)
|
411
|
+
end
|
410
412
|
end
|
411
413
|
end
|
412
414
|
end
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
415
|
+
local parentRawOpts = jobAttributes[3]
|
416
|
+
local parentOpts = cjson.decode(parentRawOpts)
|
417
|
+
removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
|
418
|
+
else
|
419
|
+
local grandParentKey = rcall("HGET", parentKey, "parentKey")
|
420
|
+
if grandParentKey then
|
421
|
+
local grandParentUnsuccesssfulSet = grandParentKey .. ":unsuccessful"
|
422
|
+
rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
|
423
|
+
end
|
422
424
|
end
|
423
425
|
end
|
424
426
|
end
|
@@ -506,7 +508,7 @@ if (#stalling > 0) then
|
|
506
508
|
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
507
509
|
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
508
510
|
rcall("ZADD", unsuccesssfulSet, timestamp, jobKey)
|
509
|
-
|
511
|
+
moveParentToFailedIfNeeded(
|
510
512
|
parentData['queueKey'],
|
511
513
|
parentData['queueKey'] .. ':' .. parentData['id'],
|
512
514
|
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;AAC1B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -235,7 +235,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
235
235
|
parentKey, parentId, timestamp)
|
236
236
|
local isParentActive = rcall("ZSCORE",
|
237
237
|
parentQueueKey .. ":waiting-children", parentId)
|
238
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
238
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
239
239
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
240
240
|
local parentWaitKey = parentQueueKey .. ":wait"
|
241
241
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -453,67 +453,69 @@ local function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestam
|
|
453
453
|
end
|
454
454
|
end
|
455
455
|
end
|
456
|
-
local function
|
457
|
-
|
458
|
-
|
459
|
-
|
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
|
-
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
487
|
-
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
488
|
-
if parentData['fpof'] then
|
489
|
-
moveParentFromWaitingChildrenToFailed(
|
490
|
-
parentData['queueKey'],
|
491
|
-
parentData['queueKey'] .. ':' .. parentData['id'],
|
492
|
-
parentData['id'],
|
493
|
-
parentKey,
|
494
|
-
timestamp
|
495
|
-
)
|
496
|
-
elseif parentData['idof'] or parentData['rdof'] then
|
456
|
+
local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
457
|
+
if rcall("EXISTS", parentKey) == 1 then
|
458
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
459
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
460
|
+
local parentPrioritizedKey = parentQueueKey .. ":prioritized"
|
461
|
+
local parentWaitingChildrenOrDelayedOrPrioritizedKey
|
462
|
+
local prevState
|
463
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
464
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentWaitingChildrenKey
|
465
|
+
prevState = "waiting-children"
|
466
|
+
elseif rcall("ZSCORE", parentDelayedKey, parentId) then
|
467
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentDelayedKey
|
468
|
+
prevState = "delayed"
|
469
|
+
elseif rcall("ZSCORE", parentPrioritizedKey, parentId) then
|
470
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentPrioritizedKey
|
471
|
+
prevState = "prioritized"
|
472
|
+
end
|
473
|
+
if parentWaitingChildrenOrDelayedOrPrioritizedKey then
|
474
|
+
rcall("ZREM", parentWaitingChildrenOrDelayedOrPrioritizedKey, parentId)
|
475
|
+
local parentQueuePrefix = parentQueueKey .. ":"
|
476
|
+
local parentFailedKey = parentQueueKey .. ":failed"
|
477
|
+
rcall("ZADD", parentFailedKey, timestamp, parentId)
|
478
|
+
local failedReason = "child " .. jobIdKey .. " failed"
|
479
|
+
rcall("HSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
|
480
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
|
481
|
+
failedReason, "prev", prevState)
|
482
|
+
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
|
483
|
+
removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
|
484
|
+
if jobAttributes[1] then
|
485
|
+
local parentData = cjson.decode(jobAttributes[1])
|
497
486
|
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
498
|
-
local
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
487
|
+
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
488
|
+
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
489
|
+
if parentData['fpof'] then
|
490
|
+
moveParentToFailedIfNeeded(
|
491
|
+
parentData['queueKey'],
|
492
|
+
parentData['queueKey'] .. ':' .. parentData['id'],
|
493
|
+
parentData['id'],
|
494
|
+
parentKey,
|
495
|
+
timestamp
|
496
|
+
)
|
497
|
+
elseif parentData['idof'] or parentData['rdof'] then
|
498
|
+
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
499
|
+
local grandParentDependenciesSet = grandParentKey .. ":dependencies"
|
500
|
+
if rcall("SREM", grandParentDependenciesSet, parentKey) == 1 then
|
501
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], grandParentDependenciesSet,
|
502
|
+
grandParentKey, parentData['id'], timestamp)
|
503
|
+
if parentData['idof'] then
|
504
|
+
local grandParentFailedSet = grandParentKey .. ":failed"
|
505
|
+
rcall("HSET", grandParentFailedSet, parentKey, failedReason)
|
506
|
+
end
|
505
507
|
end
|
506
508
|
end
|
507
509
|
end
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
510
|
+
local parentRawOpts = jobAttributes[3]
|
511
|
+
local parentOpts = cjson.decode(parentRawOpts)
|
512
|
+
removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
|
513
|
+
else
|
514
|
+
local grandParentKey = rcall("HGET", parentKey, "parentKey")
|
515
|
+
if grandParentKey then
|
516
|
+
local grandParentUnsuccesssfulSet = grandParentKey .. ":unsuccessful"
|
517
|
+
rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
|
518
|
+
end
|
517
519
|
end
|
518
520
|
end
|
519
521
|
end
|
@@ -706,7 +708,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
706
708
|
if opts['fpof'] then
|
707
709
|
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
708
710
|
rcall("ZADD", unsuccesssfulSet, timestamp, jobIdKey)
|
709
|
-
|
711
|
+
moveParentToFailedIfNeeded(parentQueueKey, parentKey,
|
710
712
|
parentId, jobIdKey,
|
711
713
|
timestamp)
|
712
714
|
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;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -137,7 +137,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
137
137
|
parentKey, parentId, timestamp)
|
138
138
|
local isParentActive = rcall("ZSCORE",
|
139
139
|
parentQueueKey .. ":waiting-children", parentId)
|
140
|
-
if rcall("SCARD", parentDependenciesKey) == 0
|
140
|
+
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
141
141
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
142
142
|
local parentWaitKey = parentQueueKey .. ":wait"
|
143
143
|
local parentPausedKey = parentQueueKey .. ":paused"
|
@@ -355,67 +355,69 @@ local function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestam
|
|
355
355
|
end
|
356
356
|
end
|
357
357
|
end
|
358
|
-
local function
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
389
|
-
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
390
|
-
if parentData['fpof'] then
|
391
|
-
moveParentFromWaitingChildrenToFailed(
|
392
|
-
parentData['queueKey'],
|
393
|
-
parentData['queueKey'] .. ':' .. parentData['id'],
|
394
|
-
parentData['id'],
|
395
|
-
parentKey,
|
396
|
-
timestamp
|
397
|
-
)
|
398
|
-
elseif parentData['idof'] or parentData['rdof'] then
|
358
|
+
local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
359
|
+
if rcall("EXISTS", parentKey) == 1 then
|
360
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
361
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
362
|
+
local parentPrioritizedKey = parentQueueKey .. ":prioritized"
|
363
|
+
local parentWaitingChildrenOrDelayedOrPrioritizedKey
|
364
|
+
local prevState
|
365
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
366
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentWaitingChildrenKey
|
367
|
+
prevState = "waiting-children"
|
368
|
+
elseif rcall("ZSCORE", parentDelayedKey, parentId) then
|
369
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentDelayedKey
|
370
|
+
prevState = "delayed"
|
371
|
+
elseif rcall("ZSCORE", parentPrioritizedKey, parentId) then
|
372
|
+
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentPrioritizedKey
|
373
|
+
prevState = "prioritized"
|
374
|
+
end
|
375
|
+
if parentWaitingChildrenOrDelayedOrPrioritizedKey then
|
376
|
+
rcall("ZREM", parentWaitingChildrenOrDelayedOrPrioritizedKey, parentId)
|
377
|
+
local parentQueuePrefix = parentQueueKey .. ":"
|
378
|
+
local parentFailedKey = parentQueueKey .. ":failed"
|
379
|
+
rcall("ZADD", parentFailedKey, timestamp, parentId)
|
380
|
+
local failedReason = "child " .. jobIdKey .. " failed"
|
381
|
+
rcall("HSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
|
382
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
|
383
|
+
failedReason, "prev", prevState)
|
384
|
+
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
|
385
|
+
removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
|
386
|
+
if jobAttributes[1] then
|
387
|
+
local parentData = cjson.decode(jobAttributes[1])
|
399
388
|
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
400
|
-
local
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
389
|
+
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
390
|
+
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
391
|
+
if parentData['fpof'] then
|
392
|
+
moveParentToFailedIfNeeded(
|
393
|
+
parentData['queueKey'],
|
394
|
+
parentData['queueKey'] .. ':' .. parentData['id'],
|
395
|
+
parentData['id'],
|
396
|
+
parentKey,
|
397
|
+
timestamp
|
398
|
+
)
|
399
|
+
elseif parentData['idof'] or parentData['rdof'] then
|
400
|
+
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
401
|
+
local grandParentDependenciesSet = grandParentKey .. ":dependencies"
|
402
|
+
if rcall("SREM", grandParentDependenciesSet, parentKey) == 1 then
|
403
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], grandParentDependenciesSet,
|
404
|
+
grandParentKey, parentData['id'], timestamp)
|
405
|
+
if parentData['idof'] then
|
406
|
+
local grandParentFailedSet = grandParentKey .. ":failed"
|
407
|
+
rcall("HSET", grandParentFailedSet, parentKey, failedReason)
|
408
|
+
end
|
407
409
|
end
|
408
410
|
end
|
409
411
|
end
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
412
|
+
local parentRawOpts = jobAttributes[3]
|
413
|
+
local parentOpts = cjson.decode(parentRawOpts)
|
414
|
+
removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
|
415
|
+
else
|
416
|
+
local grandParentKey = rcall("HGET", parentKey, "parentKey")
|
417
|
+
if grandParentKey then
|
418
|
+
local grandParentUnsuccesssfulSet = grandParentKey .. ":unsuccessful"
|
419
|
+
rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
|
420
|
+
end
|
419
421
|
end
|
420
422
|
end
|
421
423
|
end
|
@@ -438,7 +440,7 @@ local function removeLock(jobKey, stalledKey, token, jobId)
|
|
438
440
|
end
|
439
441
|
return 0
|
440
442
|
end
|
441
|
-
local function moveToWaitingChildren
|
443
|
+
local function moveToWaitingChildren(activeKey, waitingChildrenKey, jobId,
|
442
444
|
timestamp)
|
443
445
|
local score = tonumber(timestamp)
|
444
446
|
local numRemovedElements = rcall("LREM", activeKey, -1, jobId)
|
@@ -467,7 +469,7 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
467
469
|
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
468
470
|
local parentUnsuccesssful = parentKey .. ":unsuccessful"
|
469
471
|
rcall("ZADD", parentUnsuccesssful, timestamp, jobKey)
|
470
|
-
|
472
|
+
moveParentToFailedIfNeeded(
|
471
473
|
parentData['queueKey'],
|
472
474
|
parentData['queueKey'] .. ':' .. parentData['id'],
|
473
475
|
parentData['id'],
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToWaitingChildren-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToWaitingChildren-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToWaitingChildren-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToWaitingChildren-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqgBf,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|