bullmq 5.47.1 → 5.47.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/classes/scripts.js +1 -1
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/commands/includes/{moveParentToFailedIfNeeded.lua → moveChildFromDependenciesIfNeeded.lua} +40 -29
- package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +2 -2
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +2 -31
- package/dist/cjs/commands/moveToFinished-14.lua +3 -23
- package/dist/cjs/commands/moveToWaitingChildren-8.lua +2 -32
- package/dist/cjs/scripts/addDelayedJob-6.js +2 -2
- package/dist/cjs/scripts/addParentJob-4.js +2 -2
- package/dist/cjs/scripts/addPrioritizedJob-8.js +2 -2
- package/dist/cjs/scripts/addStandardJob-8.js +2 -2
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +42 -60
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +43 -52
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/moveToWaitingChildren-8.js +42 -62
- 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/classes/scripts.js +1 -1
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/commands/includes/{moveParentToFailedIfNeeded.lua → moveChildFromDependenciesIfNeeded.lua} +40 -29
- package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +2 -2
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +2 -31
- package/dist/esm/commands/moveToFinished-14.lua +3 -23
- package/dist/esm/commands/moveToWaitingChildren-8.lua +2 -32
- package/dist/esm/scripts/addDelayedJob-6.js +2 -2
- package/dist/esm/scripts/addParentJob-4.js +2 -2
- package/dist/esm/scripts/addPrioritizedJob-8.js +2 -2
- package/dist/esm/scripts/addStandardJob-8.js +2 -2
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +42 -60
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +43 -52
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/moveToWaitingChildren-8.js +42 -62
- 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
@@ -8,7 +8,9 @@
|
|
8
8
|
--- @include "removeDeduplicationKeyIfNeeded"
|
9
9
|
--- @include "removeJobsOnFail"
|
10
10
|
|
11
|
-
local
|
11
|
+
local moveParentToFailedIfNeeded
|
12
|
+
local moveChildFromDependenciesIfNeeded
|
13
|
+
moveParentToFailedIfNeeded = function (parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
12
14
|
if rcall("EXISTS", parentKey) == 1 then
|
13
15
|
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
14
16
|
local parentDelayedKey = parentQueueKey .. ":delayed"
|
@@ -40,34 +42,7 @@ local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, j
|
|
40
42
|
|
41
43
|
removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
|
42
44
|
|
43
|
-
|
44
|
-
local parentData = cjson.decode(jobAttributes[1])
|
45
|
-
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
46
|
-
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
47
|
-
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
48
|
-
if parentData['fpof'] then
|
49
|
-
moveParentToFailedIfNeeded(
|
50
|
-
parentData['queueKey'],
|
51
|
-
parentData['queueKey'] .. ':' .. parentData['id'],
|
52
|
-
parentData['id'],
|
53
|
-
parentKey,
|
54
|
-
timestamp
|
55
|
-
)
|
56
|
-
elseif parentData['cpof'] then
|
57
|
-
moveParentToWait(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
58
|
-
elseif parentData['idof'] or parentData['rdof'] then
|
59
|
-
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
60
|
-
local grandParentDependenciesSet = grandParentKey .. ":dependencies"
|
61
|
-
if rcall("SREM", grandParentDependenciesSet, parentKey) == 1 then
|
62
|
-
moveParentToWaitIfNeeded(parentData['queueKey'], grandParentDependenciesSet,
|
63
|
-
grandParentKey, parentData['id'], timestamp)
|
64
|
-
if parentData['idof'] then
|
65
|
-
local grandParentFailedSet = grandParentKey .. ":failed"
|
66
|
-
rcall("HSET", grandParentFailedSet, parentKey, failedReason)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
45
|
+
moveChildFromDependenciesIfNeeded(jobAttributes[1], parentKey, failedReason, timestamp)
|
71
46
|
|
72
47
|
local parentRawOpts = jobAttributes[3]
|
73
48
|
local parentOpts = cjson.decode(parentRawOpts)
|
@@ -83,3 +58,39 @@ local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, j
|
|
83
58
|
end
|
84
59
|
end
|
85
60
|
end
|
61
|
+
|
62
|
+
moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedReason, timestamp)
|
63
|
+
if rawParentData then
|
64
|
+
local parentData = cjson.decode(rawParentData)
|
65
|
+
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
66
|
+
local parentDependenciesChildrenKey = parentKey .. ":dependencies"
|
67
|
+
if parentData['fpof'] then
|
68
|
+
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
69
|
+
local parentUnsuccesssfulChildrenKey = parentKey .. ":unsuccessful"
|
70
|
+
rcall("ZADD", parentUnsuccesssfulChildrenKey, timestamp, childKey)
|
71
|
+
moveParentToFailedIfNeeded(
|
72
|
+
parentData['queueKey'],
|
73
|
+
parentKey,
|
74
|
+
parentData['id'],
|
75
|
+
childKey,
|
76
|
+
timestamp
|
77
|
+
)
|
78
|
+
end
|
79
|
+
elseif parentData['cpof'] then
|
80
|
+
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
81
|
+
local parentFailedChildrenKey = parentKey .. ":failed"
|
82
|
+
rcall("HSET", parentFailedChildrenKey, childKey, failedReason)
|
83
|
+
moveParentToWait(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
84
|
+
end
|
85
|
+
elseif parentData['idof'] or parentData['rdof'] then
|
86
|
+
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
87
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], parentDependenciesChildrenKey,
|
88
|
+
parentKey, parentData['id'], timestamp)
|
89
|
+
if parentData['idof'] then
|
90
|
+
local parentFailedChildrenKey = parentKey .. ":failed"
|
91
|
+
rcall("HSET", parentFailedChildrenKey, childKey, failedReason)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
]]
|
4
4
|
--- @include "moveParentToWait"
|
5
5
|
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
6
|
-
local
|
7
|
-
if
|
6
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
7
|
+
if doNotHavePendingDependencies then
|
8
8
|
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
9
9
|
end
|
10
10
|
end
|
@@ -26,7 +26,7 @@ local rcall = redis.call
|
|
26
26
|
--- @include "includes/addJobInTargetList"
|
27
27
|
--- @include "includes/batches"
|
28
28
|
--- @include "includes/getTargetQueueList"
|
29
|
-
--- @include "includes/
|
29
|
+
--- @include "includes/moveChildFromDependenciesIfNeeded"
|
30
30
|
--- @include "includes/moveParentToWaitIfNeeded"
|
31
31
|
--- @include "includes/moveParentToWait"
|
32
32
|
--- @include "includes/removeDeduplicationKeyIfNeeded"
|
@@ -93,36 +93,7 @@ if (#stalling > 0) then
|
|
93
93
|
rcall("XADD", eventStreamKey, "*", "event", "failed", "jobId", jobId, 'prev', 'active',
|
94
94
|
'failedReason', failedReason)
|
95
95
|
|
96
|
-
|
97
|
-
if opts['fpof'] or opts['cpof'] then
|
98
|
-
local parentData = cjson.decode(rawParentData)
|
99
|
-
-- TODO: need to remove this job from dependencies set in next breaking change
|
100
|
-
-- no for now as it would imply a breaking change
|
101
|
-
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
102
|
-
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
103
|
-
rcall("ZADD", unsuccesssfulSet, timestamp, jobKey)
|
104
|
-
|
105
|
-
if opts['fpof'] then
|
106
|
-
moveParentToFailedIfNeeded(parentData['queueKey'],
|
107
|
-
parentData['queueKey'] .. ':' .. parentData['id'], parentData['id'], jobKey,
|
108
|
-
timestamp)
|
109
|
-
elseif opts['cpof'] then
|
110
|
-
moveParentToWait(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
111
|
-
end
|
112
|
-
elseif opts['idof'] or opts['rdof'] then
|
113
|
-
local parentData = cjson.decode(rawParentData)
|
114
|
-
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
115
|
-
local dependenciesSet = parentKey .. ":dependencies"
|
116
|
-
if rcall("SREM", dependenciesSet, jobKey) == 1 then
|
117
|
-
moveParentToWaitIfNeeded(parentData['queueKey'], dependenciesSet, parentKey,
|
118
|
-
parentData['id'], timestamp)
|
119
|
-
if opts['idof'] then
|
120
|
-
local failedSet = parentKey .. ":failed"
|
121
|
-
rcall("HSET", failedSet, jobKey, failedReason)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
96
|
+
moveChildFromDependenciesIfNeeded(rawParentData, jobKey, failedReason, timestamp)
|
126
97
|
|
127
98
|
removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestamp)
|
128
99
|
|
@@ -64,7 +64,7 @@ local rcall = redis.call
|
|
64
64
|
--- @include "includes/getRateLimitTTL"
|
65
65
|
--- @include "includes/getTargetQueueList"
|
66
66
|
--- @include "includes/moveJobFromPriorityToActive"
|
67
|
-
--- @include "includes/
|
67
|
+
--- @include "includes/moveChildFromDependenciesIfNeeded"
|
68
68
|
--- @include "includes/moveParentToWait"
|
69
69
|
--- @include "includes/moveParentToWaitIfNeeded"
|
70
70
|
--- @include "includes/prepareJobForProcessing"
|
@@ -109,7 +109,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
109
109
|
local parentKey = jobAttributes[1] or ""
|
110
110
|
local parentId = ""
|
111
111
|
local parentQueueKey = ""
|
112
|
-
if jobAttributes[2] then
|
112
|
+
if jobAttributes[2] then -- TODO: need to revisit this logic if it's still needed
|
113
113
|
local jsonDecodedParent = cjson.decode(jobAttributes[2])
|
114
114
|
parentId = jsonDecodedParent['id']
|
115
115
|
parentQueueKey = jsonDecodedParent['queueKey']
|
@@ -152,27 +152,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
152
152
|
timestamp)
|
153
153
|
end
|
154
154
|
else
|
155
|
-
|
156
|
-
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
157
|
-
rcall("ZADD", unsuccesssfulSet, timestamp, jobIdKey)
|
158
|
-
|
159
|
-
if opts['fpof'] then
|
160
|
-
moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
161
|
-
elseif opts['cpof'] then
|
162
|
-
local failedSet = parentKey .. ":failed"
|
163
|
-
rcall("HSET", failedSet, jobIdKey, ARGV[4])
|
164
|
-
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
165
|
-
end
|
166
|
-
elseif opts['idof'] or opts['rdof'] then
|
167
|
-
local dependenciesSet = parentKey .. ":dependencies"
|
168
|
-
if rcall("SREM", dependenciesSet, jobIdKey) == 1 then
|
169
|
-
moveParentToWaitIfNeeded(parentQueueKey, dependenciesSet, parentKey, parentId, timestamp)
|
170
|
-
if opts['idof'] then
|
171
|
-
local failedSet = parentKey .. ":failed"
|
172
|
-
rcall("HSET", failedSet, jobIdKey, ARGV[4])
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
155
|
+
moveChildFromDependenciesIfNeeded(jobAttributes[2], jobIdKey, ARGV[4], timestamp)
|
176
156
|
end
|
177
157
|
end
|
178
158
|
|
@@ -36,7 +36,7 @@ local timestamp = ARGV[3]
|
|
36
36
|
local jobId = ARGV[4]
|
37
37
|
|
38
38
|
--- Includes
|
39
|
-
--- @include "includes/
|
39
|
+
--- @include "includes/moveChildFromDependenciesIfNeeded"
|
40
40
|
--- @include "includes/moveParentToWait"
|
41
41
|
--- @include "includes/moveParentToWaitIfNeeded"
|
42
42
|
--- @include "includes/removeDeduplicationKeyIfNeeded"
|
@@ -75,37 +75,7 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
75
75
|
local rawOpts = jobAttributes[3]
|
76
76
|
local opts = cjson.decode(rawOpts)
|
77
77
|
|
78
|
-
|
79
|
-
if opts['fpof'] or opts['cpof'] then
|
80
|
-
local parentData = cjson.decode(rawParentData)
|
81
|
-
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
82
|
-
local parentUnsuccesssful = parentKey .. ":unsuccessful"
|
83
|
-
rcall("ZADD", parentUnsuccesssful, timestamp, jobKey)
|
84
|
-
if opts['fpof'] then
|
85
|
-
moveParentToFailedIfNeeded(
|
86
|
-
parentData['queueKey'],
|
87
|
-
parentData['queueKey'] .. ':' .. parentData['id'],
|
88
|
-
parentData['id'],
|
89
|
-
jobKey,
|
90
|
-
timestamp
|
91
|
-
)
|
92
|
-
elseif opts['cpof'] then
|
93
|
-
moveParentToWait(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
94
|
-
end
|
95
|
-
elseif opts['idof'] or opts['rdof'] then
|
96
|
-
local parentData = cjson.decode(rawParentData)
|
97
|
-
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
98
|
-
local dependenciesSet = parentKey .. ":dependencies"
|
99
|
-
if rcall("SREM", dependenciesSet, jobKey) == 1 then
|
100
|
-
moveParentToWaitIfNeeded(parentData['queueKey'], dependenciesSet,
|
101
|
-
parentKey, parentData['id'], timestamp)
|
102
|
-
if opts['idof'] then
|
103
|
-
local failedSet = parentKey .. ":failed"
|
104
|
-
rcall("HSET", failedSet, jobKey, failedReason)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
78
|
+
moveChildFromDependenciesIfNeeded(rawParentData, jobKey, failedReason, timestamp)
|
109
79
|
|
110
80
|
removeJobsOnFail(ARGV[5], failedKey, jobId, opts, timestamp)
|
111
81
|
|
@@ -270,8 +270,8 @@ local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
|
270
270
|
end
|
271
271
|
end
|
272
272
|
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
273
|
-
local
|
274
|
-
if
|
273
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
274
|
+
if doNotHavePendingDependencies then
|
275
275
|
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
276
276
|
end
|
277
277
|
end
|
@@ -226,8 +226,8 @@ local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
|
226
226
|
end
|
227
227
|
end
|
228
228
|
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
229
|
-
local
|
230
|
-
if
|
229
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
230
|
+
if doNotHavePendingDependencies then
|
231
231
|
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
232
232
|
end
|
233
233
|
end
|
@@ -263,8 +263,8 @@ local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
266
|
-
local
|
267
|
-
if
|
266
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
267
|
+
if doNotHavePendingDependencies then
|
268
268
|
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
269
269
|
end
|
270
270
|
end
|
@@ -236,8 +236,8 @@ local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
|
236
236
|
end
|
237
237
|
end
|
238
238
|
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
239
|
-
local
|
240
|
-
if
|
239
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
240
|
+
if doNotHavePendingDependencies then
|
241
241
|
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
242
242
|
end
|
243
243
|
end
|
@@ -175,8 +175,8 @@ local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
178
|
-
local
|
179
|
-
if
|
178
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
179
|
+
if doNotHavePendingDependencies then
|
180
180
|
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
181
181
|
end
|
182
182
|
end
|
@@ -362,7 +362,9 @@ local function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestam
|
|
362
362
|
end
|
363
363
|
end
|
364
364
|
end
|
365
|
-
local
|
365
|
+
local moveParentToFailedIfNeeded
|
366
|
+
local moveChildFromDependenciesIfNeeded
|
367
|
+
moveParentToFailedIfNeeded = function (parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
366
368
|
if rcall("EXISTS", parentKey) == 1 then
|
367
369
|
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
368
370
|
local parentDelayedKey = parentQueueKey .. ":delayed"
|
@@ -390,34 +392,7 @@ local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, j
|
|
390
392
|
failedReason, "prev", prevState)
|
391
393
|
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
|
392
394
|
removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
|
393
|
-
|
394
|
-
local parentData = cjson.decode(jobAttributes[1])
|
395
|
-
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
396
|
-
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
397
|
-
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
398
|
-
if parentData['fpof'] then
|
399
|
-
moveParentToFailedIfNeeded(
|
400
|
-
parentData['queueKey'],
|
401
|
-
parentData['queueKey'] .. ':' .. parentData['id'],
|
402
|
-
parentData['id'],
|
403
|
-
parentKey,
|
404
|
-
timestamp
|
405
|
-
)
|
406
|
-
elseif parentData['cpof'] then
|
407
|
-
moveParentToWait(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
408
|
-
elseif parentData['idof'] or parentData['rdof'] then
|
409
|
-
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
410
|
-
local grandParentDependenciesSet = grandParentKey .. ":dependencies"
|
411
|
-
if rcall("SREM", grandParentDependenciesSet, parentKey) == 1 then
|
412
|
-
moveParentToWaitIfNeeded(parentData['queueKey'], grandParentDependenciesSet,
|
413
|
-
grandParentKey, parentData['id'], timestamp)
|
414
|
-
if parentData['idof'] then
|
415
|
-
local grandParentFailedSet = grandParentKey .. ":failed"
|
416
|
-
rcall("HSET", grandParentFailedSet, parentKey, failedReason)
|
417
|
-
end
|
418
|
-
end
|
419
|
-
end
|
420
|
-
end
|
395
|
+
moveChildFromDependenciesIfNeeded(jobAttributes[1], parentKey, failedReason, timestamp)
|
421
396
|
local parentRawOpts = jobAttributes[3]
|
422
397
|
local parentOpts = cjson.decode(parentRawOpts)
|
423
398
|
removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
|
@@ -430,6 +405,41 @@ local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, j
|
|
430
405
|
end
|
431
406
|
end
|
432
407
|
end
|
408
|
+
moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedReason, timestamp)
|
409
|
+
if rawParentData then
|
410
|
+
local parentData = cjson.decode(rawParentData)
|
411
|
+
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
412
|
+
local parentDependenciesChildrenKey = parentKey .. ":dependencies"
|
413
|
+
if parentData['fpof'] then
|
414
|
+
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
415
|
+
local parentUnsuccesssfulChildrenKey = parentKey .. ":unsuccessful"
|
416
|
+
rcall("ZADD", parentUnsuccesssfulChildrenKey, timestamp, childKey)
|
417
|
+
moveParentToFailedIfNeeded(
|
418
|
+
parentData['queueKey'],
|
419
|
+
parentKey,
|
420
|
+
parentData['id'],
|
421
|
+
childKey,
|
422
|
+
timestamp
|
423
|
+
)
|
424
|
+
end
|
425
|
+
elseif parentData['cpof'] then
|
426
|
+
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
427
|
+
local parentFailedChildrenKey = parentKey .. ":failed"
|
428
|
+
rcall("HSET", parentFailedChildrenKey, childKey, failedReason)
|
429
|
+
moveParentToWait(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
430
|
+
end
|
431
|
+
elseif parentData['idof'] or parentData['rdof'] then
|
432
|
+
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
433
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], parentDependenciesChildrenKey,
|
434
|
+
parentKey, parentData['id'], timestamp)
|
435
|
+
if parentData['idof'] then
|
436
|
+
local parentFailedChildrenKey = parentKey .. ":failed"
|
437
|
+
rcall("HSET", parentFailedChildrenKey, childKey, failedReason)
|
438
|
+
end
|
439
|
+
end
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
433
443
|
--[[
|
434
444
|
Function to trim events, default 10000.
|
435
445
|
]]
|
@@ -504,35 +514,7 @@ if (#stalling > 0) then
|
|
504
514
|
rcall("HMSET", jobKey, "failedReason", failedReason, "finishedOn", timestamp)
|
505
515
|
rcall("XADD", eventStreamKey, "*", "event", "failed", "jobId", jobId, 'prev', 'active',
|
506
516
|
'failedReason', failedReason)
|
507
|
-
|
508
|
-
if opts['fpof'] or opts['cpof'] then
|
509
|
-
local parentData = cjson.decode(rawParentData)
|
510
|
-
-- TODO: need to remove this job from dependencies set in next breaking change
|
511
|
-
-- no for now as it would imply a breaking change
|
512
|
-
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
513
|
-
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
514
|
-
rcall("ZADD", unsuccesssfulSet, timestamp, jobKey)
|
515
|
-
if opts['fpof'] then
|
516
|
-
moveParentToFailedIfNeeded(parentData['queueKey'],
|
517
|
-
parentData['queueKey'] .. ':' .. parentData['id'], parentData['id'], jobKey,
|
518
|
-
timestamp)
|
519
|
-
elseif opts['cpof'] then
|
520
|
-
moveParentToWait(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
521
|
-
end
|
522
|
-
elseif opts['idof'] or opts['rdof'] then
|
523
|
-
local parentData = cjson.decode(rawParentData)
|
524
|
-
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
525
|
-
local dependenciesSet = parentKey .. ":dependencies"
|
526
|
-
if rcall("SREM", dependenciesSet, jobKey) == 1 then
|
527
|
-
moveParentToWaitIfNeeded(parentData['queueKey'], dependenciesSet, parentKey,
|
528
|
-
parentData['id'], timestamp)
|
529
|
-
if opts['idof'] then
|
530
|
-
local failedSet = parentKey .. ":failed"
|
531
|
-
rcall("HSET", failedSet, jobKey, failedReason)
|
532
|
-
end
|
533
|
-
end
|
534
|
-
end
|
535
|
-
end
|
517
|
+
moveChildFromDependenciesIfNeeded(rawParentData, jobKey, failedReason, timestamp)
|
536
518
|
removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestamp)
|
537
519
|
table.insert(failed, jobId)
|
538
520
|
else
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6hBf,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -271,8 +271,8 @@ local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
|
271
271
|
end
|
272
272
|
end
|
273
273
|
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
274
|
-
local
|
275
|
-
if
|
274
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
275
|
+
if doNotHavePendingDependencies then
|
276
276
|
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
277
277
|
end
|
278
278
|
end
|
@@ -458,7 +458,9 @@ local function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestam
|
|
458
458
|
end
|
459
459
|
end
|
460
460
|
end
|
461
|
-
local
|
461
|
+
local moveParentToFailedIfNeeded
|
462
|
+
local moveChildFromDependenciesIfNeeded
|
463
|
+
moveParentToFailedIfNeeded = function (parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
462
464
|
if rcall("EXISTS", parentKey) == 1 then
|
463
465
|
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
464
466
|
local parentDelayedKey = parentQueueKey .. ":delayed"
|
@@ -486,34 +488,7 @@ local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, j
|
|
486
488
|
failedReason, "prev", prevState)
|
487
489
|
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
|
488
490
|
removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
|
489
|
-
|
490
|
-
local parentData = cjson.decode(jobAttributes[1])
|
491
|
-
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
492
|
-
local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
|
493
|
-
rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
|
494
|
-
if parentData['fpof'] then
|
495
|
-
moveParentToFailedIfNeeded(
|
496
|
-
parentData['queueKey'],
|
497
|
-
parentData['queueKey'] .. ':' .. parentData['id'],
|
498
|
-
parentData['id'],
|
499
|
-
parentKey,
|
500
|
-
timestamp
|
501
|
-
)
|
502
|
-
elseif parentData['cpof'] then
|
503
|
-
moveParentToWait(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
504
|
-
elseif parentData['idof'] or parentData['rdof'] then
|
505
|
-
local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
506
|
-
local grandParentDependenciesSet = grandParentKey .. ":dependencies"
|
507
|
-
if rcall("SREM", grandParentDependenciesSet, parentKey) == 1 then
|
508
|
-
moveParentToWaitIfNeeded(parentData['queueKey'], grandParentDependenciesSet,
|
509
|
-
grandParentKey, parentData['id'], timestamp)
|
510
|
-
if parentData['idof'] then
|
511
|
-
local grandParentFailedSet = grandParentKey .. ":failed"
|
512
|
-
rcall("HSET", grandParentFailedSet, parentKey, failedReason)
|
513
|
-
end
|
514
|
-
end
|
515
|
-
end
|
516
|
-
end
|
491
|
+
moveChildFromDependenciesIfNeeded(jobAttributes[1], parentKey, failedReason, timestamp)
|
517
492
|
local parentRawOpts = jobAttributes[3]
|
518
493
|
local parentOpts = cjson.decode(parentRawOpts)
|
519
494
|
removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
|
@@ -526,6 +501,41 @@ local function moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, j
|
|
526
501
|
end
|
527
502
|
end
|
528
503
|
end
|
504
|
+
moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedReason, timestamp)
|
505
|
+
if rawParentData then
|
506
|
+
local parentData = cjson.decode(rawParentData)
|
507
|
+
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
508
|
+
local parentDependenciesChildrenKey = parentKey .. ":dependencies"
|
509
|
+
if parentData['fpof'] then
|
510
|
+
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
511
|
+
local parentUnsuccesssfulChildrenKey = parentKey .. ":unsuccessful"
|
512
|
+
rcall("ZADD", parentUnsuccesssfulChildrenKey, timestamp, childKey)
|
513
|
+
moveParentToFailedIfNeeded(
|
514
|
+
parentData['queueKey'],
|
515
|
+
parentKey,
|
516
|
+
parentData['id'],
|
517
|
+
childKey,
|
518
|
+
timestamp
|
519
|
+
)
|
520
|
+
end
|
521
|
+
elseif parentData['cpof'] then
|
522
|
+
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
523
|
+
local parentFailedChildrenKey = parentKey .. ":failed"
|
524
|
+
rcall("HSET", parentFailedChildrenKey, childKey, failedReason)
|
525
|
+
moveParentToWait(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
526
|
+
end
|
527
|
+
elseif parentData['idof'] or parentData['rdof'] then
|
528
|
+
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
529
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], parentDependenciesChildrenKey,
|
530
|
+
parentKey, parentData['id'], timestamp)
|
531
|
+
if parentData['idof'] then
|
532
|
+
local parentFailedChildrenKey = parentKey .. ":failed"
|
533
|
+
rcall("HSET", parentFailedChildrenKey, childKey, failedReason)
|
534
|
+
end
|
535
|
+
end
|
536
|
+
end
|
537
|
+
end
|
538
|
+
end
|
529
539
|
--[[
|
530
540
|
Function to move job from wait state to active.
|
531
541
|
Input:
|
@@ -682,7 +692,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
682
692
|
local parentKey = jobAttributes[1] or ""
|
683
693
|
local parentId = ""
|
684
694
|
local parentQueueKey = ""
|
685
|
-
if jobAttributes[2] then
|
695
|
+
if jobAttributes[2] then -- TODO: need to revisit this logic if it's still needed
|
686
696
|
local jsonDecodedParent = cjson.decode(jobAttributes[2])
|
687
697
|
parentId = jsonDecodedParent['id']
|
688
698
|
parentQueueKey = jsonDecodedParent['queueKey']
|
@@ -717,26 +727,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
717
727
|
timestamp)
|
718
728
|
end
|
719
729
|
else
|
720
|
-
|
721
|
-
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
722
|
-
rcall("ZADD", unsuccesssfulSet, timestamp, jobIdKey)
|
723
|
-
if opts['fpof'] then
|
724
|
-
moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
725
|
-
elseif opts['cpof'] then
|
726
|
-
local failedSet = parentKey .. ":failed"
|
727
|
-
rcall("HSET", failedSet, jobIdKey, ARGV[4])
|
728
|
-
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
729
|
-
end
|
730
|
-
elseif opts['idof'] or opts['rdof'] then
|
731
|
-
local dependenciesSet = parentKey .. ":dependencies"
|
732
|
-
if rcall("SREM", dependenciesSet, jobIdKey) == 1 then
|
733
|
-
moveParentToWaitIfNeeded(parentQueueKey, dependenciesSet, parentKey, parentId, timestamp)
|
734
|
-
if opts['idof'] then
|
735
|
-
local failedSet = parentKey .. ":failed"
|
736
|
-
rcall("HSET", failedSet, jobIdKey, ARGV[4])
|
737
|
-
end
|
738
|
-
end
|
739
|
-
end
|
730
|
+
moveChildFromDependenciesIfNeeded(jobAttributes[2], jobIdKey, ARGV[4], timestamp)
|
740
731
|
end
|
741
732
|
end
|
742
733
|
local attemptsMade = rcall("HINCRBY", jobIdKey, "atm", 1)
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8zBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|