bullmq 5.49.1 → 5.49.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/job.js +3 -0
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/worker.js +4 -0
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +15 -31
- package/dist/cjs/commands/includes/moveParentToWait.lua +32 -33
- package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +8 -4
- package/dist/cjs/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
- package/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +2 -2
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +0 -2
- package/dist/cjs/commands/moveToFinished-14.lua +5 -3
- package/dist/cjs/commands/moveToWaitingChildren-8.lua +0 -2
- package/dist/cjs/scripts/addDelayedJob-6.js +51 -37
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +51 -37
- package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js +51 -37
- package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/cjs/scripts/addStandardJob-8.js +51 -37
- package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +64 -61
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +69 -63
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/moveToWaitingChildren-8.js +64 -61
- 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/job.d.ts +5 -0
- package/dist/esm/classes/job.js +3 -0
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/worker.js +5 -1
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +15 -31
- package/dist/esm/commands/includes/moveParentToWait.lua +32 -33
- package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +8 -4
- package/dist/esm/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
- package/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +2 -2
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +0 -2
- package/dist/esm/commands/moveToFinished-14.lua +5 -3
- package/dist/esm/commands/moveToWaitingChildren-8.lua +0 -2
- package/dist/esm/interfaces/job-json.d.ts +1 -0
- package/dist/esm/scripts/addDelayedJob-6.js +51 -37
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addParentJob-4.js +51 -37
- package/dist/esm/scripts/addParentJob-4.js.map +1 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js +51 -37
- package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/esm/scripts/addStandardJob-8.js +51 -37
- package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +64 -61
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +69 -63
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/moveToWaitingChildren-8.js +64 -61
- 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
@@ -167,12 +167,19 @@ end
|
|
167
167
|
Function to recursively move from waitingChildren to failed.
|
168
168
|
]]
|
169
169
|
-- Includes
|
170
|
+
--[[
|
171
|
+
Validate and move parent to a wait status (waiting, delayed or prioritized)
|
172
|
+
if no pending dependencies.
|
173
|
+
]]
|
174
|
+
-- Includes
|
170
175
|
--[[
|
171
176
|
Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
|
172
177
|
]]
|
178
|
+
-- Includes
|
173
179
|
--[[
|
174
|
-
|
180
|
+
Move parent to a wait status (wait, prioritized or delayed)
|
175
181
|
]]
|
182
|
+
-- Includes
|
176
183
|
--[[
|
177
184
|
Add delay marker if needed.
|
178
185
|
]]
|
@@ -235,46 +242,53 @@ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
|
|
235
242
|
return false
|
236
243
|
end
|
237
244
|
local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
238
|
-
local
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
245
|
+
local parentWaitKey = parentQueueKey .. ":wait"
|
246
|
+
local parentPausedKey = parentQueueKey .. ":paused"
|
247
|
+
local parentActiveKey = parentQueueKey .. ":active"
|
248
|
+
local parentMetaKey = parentQueueKey .. ":meta"
|
249
|
+
local parentMarkerKey = parentQueueKey .. ":marker"
|
250
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
251
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
252
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
253
|
+
-- ignore dependencies if any left
|
254
|
+
rcall("HSET", parentKey, "igdp", 1)
|
255
|
+
if delay > 0 then
|
256
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
257
|
+
local score = delayedTimestamp * 0x1000
|
258
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
259
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
260
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
|
261
|
+
delayedTimestamp)
|
262
|
+
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
263
|
+
else
|
264
|
+
if priority == 0 then
|
265
|
+
local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
|
266
|
+
parentWaitKey, parentPausedKey)
|
267
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
258
268
|
else
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
263
|
-
else
|
264
|
-
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
265
|
-
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
266
|
-
parentQueueKey .. ":pc", isPausedOrMaxed)
|
267
|
-
end
|
268
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
269
|
-
"waiting-children")
|
269
|
+
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
270
|
+
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
271
|
+
parentQueueKey .. ":pc", isPausedOrMaxed)
|
270
272
|
end
|
273
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
274
|
+
"waiting-children")
|
271
275
|
end
|
272
276
|
end
|
273
|
-
local function moveParentToWaitIfNeeded(parentQueueKey,
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
278
|
+
if rcall("EXISTS", parentKey) == 1 then
|
279
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
280
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
281
|
+
rcall("ZREM", parentWaitingChildrenKey, parentId)
|
282
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
277
283
|
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
|
287
|
+
parentId, timestamp)
|
288
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
289
|
+
if doNotHavePendingDependencies then
|
290
|
+
moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
291
|
+
end
|
278
292
|
end
|
279
293
|
--[[
|
280
294
|
Function to remove deduplication key if needed.
|
@@ -465,38 +479,27 @@ moveParentToFailedIfNeeded = function (parentQueueKey, parentKey, parentId, jobI
|
|
465
479
|
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
466
480
|
local parentDelayedKey = parentQueueKey .. ":delayed"
|
467
481
|
local parentPrioritizedKey = parentQueueKey .. ":prioritized"
|
468
|
-
local
|
482
|
+
local parentWaitingChildrenOrDelayedKey
|
469
483
|
local prevState
|
470
484
|
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
471
|
-
|
485
|
+
parentWaitingChildrenOrDelayedKey = parentWaitingChildrenKey
|
472
486
|
prevState = "waiting-children"
|
473
487
|
elseif rcall("ZSCORE", parentDelayedKey, parentId) then
|
474
|
-
|
488
|
+
parentWaitingChildrenOrDelayedKey = parentDelayedKey
|
475
489
|
prevState = "delayed"
|
476
|
-
|
477
|
-
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentPrioritizedKey
|
478
|
-
prevState = "prioritized"
|
490
|
+
rcall("HSET", parentKey, "delay", 0)
|
479
491
|
end
|
480
|
-
if
|
481
|
-
rcall("ZREM",
|
492
|
+
if parentWaitingChildrenOrDelayedKey then
|
493
|
+
rcall("ZREM", parentWaitingChildrenOrDelayedKey, parentId)
|
482
494
|
local parentQueuePrefix = parentQueueKey .. ":"
|
483
495
|
local parentFailedKey = parentQueueKey .. ":failed"
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
|
488
|
-
failedReason, "prev", prevState)
|
489
|
-
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
|
490
|
-
removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
|
491
|
-
moveChildFromDependenciesIfNeeded(jobAttributes[1], parentKey, failedReason, timestamp)
|
492
|
-
local parentRawOpts = jobAttributes[3]
|
493
|
-
local parentOpts = cjson.decode(parentRawOpts)
|
494
|
-
removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
|
496
|
+
local deferredFailure = "child " .. jobIdKey .. " failed"
|
497
|
+
rcall("HSET", parentKey, "defa", deferredFailure)
|
498
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
495
499
|
else
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
|
500
|
+
if not rcall("ZSCORE", parentQueueKey .. ":failed", parentId) then
|
501
|
+
local deferredFailure = "child " .. jobIdKey .. " failed"
|
502
|
+
rcall("HSET", parentKey, "defa", deferredFailure)
|
500
503
|
end
|
501
504
|
end
|
502
505
|
end
|
@@ -522,11 +525,11 @@ moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedRea
|
|
522
525
|
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
523
526
|
local parentFailedChildrenKey = parentKey .. ":failed"
|
524
527
|
rcall("HSET", parentFailedChildrenKey, childKey, failedReason)
|
525
|
-
|
528
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
526
529
|
end
|
527
530
|
elseif parentData['idof'] or parentData['rdof'] then
|
528
531
|
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
529
|
-
|
532
|
+
moveParentToWaitIfNoPendingDependencies(parentData['queueKey'], parentDependenciesChildrenKey,
|
530
533
|
parentKey, parentData['id'], timestamp)
|
531
534
|
if parentData['idof'] then
|
532
535
|
local parentFailedChildrenKey = parentKey .. ":failed"
|
@@ -655,7 +658,7 @@ local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDepende
|
|
655
658
|
parentId, jobIdKey, returnvalue, timestamp )
|
656
659
|
local processedSet = parentKey .. ":processed"
|
657
660
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
658
|
-
|
661
|
+
moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
659
662
|
end
|
660
663
|
--[[
|
661
664
|
Function to update a bunch of fields in a job.
|
@@ -736,8 +739,11 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
736
739
|
local targetSet = KEYS[11]
|
737
740
|
-- Add to complete/failed set
|
738
741
|
rcall("ZADD", targetSet, timestamp, jobId)
|
739
|
-
rcall("
|
742
|
+
rcall("HSET", jobIdKey, ARGV[3], ARGV[4], "finishedOn", timestamp)
|
740
743
|
-- "returnvalue" / "failedReason" and "finishedOn"
|
744
|
+
if ARGV[5] == "failed" then
|
745
|
+
rcall("HDEL", jobIdKey, "defa")
|
746
|
+
end
|
741
747
|
-- Remove old jobs?
|
742
748
|
if maxAge ~= nil then
|
743
749
|
removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAo0Bf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -36,12 +36,19 @@ local jobId = ARGV[4]
|
|
36
36
|
Function to recursively move from waitingChildren to failed.
|
37
37
|
]]
|
38
38
|
-- Includes
|
39
|
+
--[[
|
40
|
+
Validate and move parent to a wait status (waiting, delayed or prioritized)
|
41
|
+
if no pending dependencies.
|
42
|
+
]]
|
43
|
+
-- Includes
|
39
44
|
--[[
|
40
45
|
Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
|
41
46
|
]]
|
47
|
+
-- Includes
|
42
48
|
--[[
|
43
|
-
|
49
|
+
Move parent to a wait status (wait, prioritized or delayed)
|
44
50
|
]]
|
51
|
+
-- Includes
|
45
52
|
--[[
|
46
53
|
Add delay marker if needed.
|
47
54
|
]]
|
@@ -136,46 +143,53 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
136
143
|
return waitKey, false
|
137
144
|
end
|
138
145
|
local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
139
|
-
local
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
146
|
+
local parentWaitKey = parentQueueKey .. ":wait"
|
147
|
+
local parentPausedKey = parentQueueKey .. ":paused"
|
148
|
+
local parentActiveKey = parentQueueKey .. ":active"
|
149
|
+
local parentMetaKey = parentQueueKey .. ":meta"
|
150
|
+
local parentMarkerKey = parentQueueKey .. ":marker"
|
151
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
152
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
153
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
154
|
+
-- ignore dependencies if any left
|
155
|
+
rcall("HSET", parentKey, "igdp", 1)
|
156
|
+
if delay > 0 then
|
157
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
158
|
+
local score = delayedTimestamp * 0x1000
|
159
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
160
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
161
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
|
162
|
+
delayedTimestamp)
|
163
|
+
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
164
|
+
else
|
165
|
+
if priority == 0 then
|
166
|
+
local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
|
167
|
+
parentWaitKey, parentPausedKey)
|
168
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
159
169
|
else
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
164
|
-
else
|
165
|
-
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
166
|
-
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
167
|
-
parentQueueKey .. ":pc", isPausedOrMaxed)
|
168
|
-
end
|
169
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
170
|
-
"waiting-children")
|
170
|
+
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
171
|
+
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
172
|
+
parentQueueKey .. ":pc", isPausedOrMaxed)
|
171
173
|
end
|
174
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
175
|
+
"waiting-children")
|
172
176
|
end
|
173
177
|
end
|
174
|
-
local function moveParentToWaitIfNeeded(parentQueueKey,
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
179
|
+
if rcall("EXISTS", parentKey) == 1 then
|
180
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
181
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
182
|
+
rcall("ZREM", parentWaitingChildrenKey, parentId)
|
183
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
178
184
|
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
|
188
|
+
parentId, timestamp)
|
189
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
190
|
+
if doNotHavePendingDependencies then
|
191
|
+
moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
192
|
+
end
|
179
193
|
end
|
180
194
|
--[[
|
181
195
|
Function to remove deduplication key if needed.
|
@@ -366,38 +380,27 @@ moveParentToFailedIfNeeded = function (parentQueueKey, parentKey, parentId, jobI
|
|
366
380
|
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
367
381
|
local parentDelayedKey = parentQueueKey .. ":delayed"
|
368
382
|
local parentPrioritizedKey = parentQueueKey .. ":prioritized"
|
369
|
-
local
|
383
|
+
local parentWaitingChildrenOrDelayedKey
|
370
384
|
local prevState
|
371
385
|
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
372
|
-
|
386
|
+
parentWaitingChildrenOrDelayedKey = parentWaitingChildrenKey
|
373
387
|
prevState = "waiting-children"
|
374
388
|
elseif rcall("ZSCORE", parentDelayedKey, parentId) then
|
375
|
-
|
389
|
+
parentWaitingChildrenOrDelayedKey = parentDelayedKey
|
376
390
|
prevState = "delayed"
|
377
|
-
|
378
|
-
parentWaitingChildrenOrDelayedOrPrioritizedKey = parentPrioritizedKey
|
379
|
-
prevState = "prioritized"
|
391
|
+
rcall("HSET", parentKey, "delay", 0)
|
380
392
|
end
|
381
|
-
if
|
382
|
-
rcall("ZREM",
|
393
|
+
if parentWaitingChildrenOrDelayedKey then
|
394
|
+
rcall("ZREM", parentWaitingChildrenOrDelayedKey, parentId)
|
383
395
|
local parentQueuePrefix = parentQueueKey .. ":"
|
384
396
|
local parentFailedKey = parentQueueKey .. ":failed"
|
385
|
-
|
386
|
-
|
387
|
-
|
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
|
-
moveChildFromDependenciesIfNeeded(jobAttributes[1], parentKey, failedReason, timestamp)
|
393
|
-
local parentRawOpts = jobAttributes[3]
|
394
|
-
local parentOpts = cjson.decode(parentRawOpts)
|
395
|
-
removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
|
397
|
+
local deferredFailure = "child " .. jobIdKey .. " failed"
|
398
|
+
rcall("HSET", parentKey, "defa", deferredFailure)
|
399
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
396
400
|
else
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
|
401
|
+
if not rcall("ZSCORE", parentQueueKey .. ":failed", parentId) then
|
402
|
+
local deferredFailure = "child " .. jobIdKey .. " failed"
|
403
|
+
rcall("HSET", parentKey, "defa", deferredFailure)
|
401
404
|
end
|
402
405
|
end
|
403
406
|
end
|
@@ -423,11 +426,11 @@ moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedRea
|
|
423
426
|
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
424
427
|
local parentFailedChildrenKey = parentKey .. ":failed"
|
425
428
|
rcall("HSET", parentFailedChildrenKey, childKey, failedReason)
|
426
|
-
|
429
|
+
moveParentToWaitIfNeeded(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
427
430
|
end
|
428
431
|
elseif parentData['idof'] or parentData['rdof'] then
|
429
432
|
if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
|
430
|
-
|
433
|
+
moveParentToWaitIfNoPendingDependencies(parentData['queueKey'], parentDependenciesChildrenKey,
|
431
434
|
parentKey, parentData['id'], timestamp)
|
432
435
|
if parentData['idof'] then
|
433
436
|
local parentFailedChildrenKey = parentKey .. ":failed"
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8ff,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|