bullmq 5.41.9 → 5.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/cjs/classes/job-scheduler.js +3 -0
  2. package/dist/cjs/classes/job-scheduler.js.map +1 -1
  3. package/dist/cjs/classes/job.js +20 -13
  4. package/dist/cjs/classes/job.js.map +1 -1
  5. package/dist/cjs/classes/scripts.js +5 -1
  6. package/dist/cjs/classes/scripts.js.map +1 -1
  7. package/dist/cjs/classes/worker.js +4 -8
  8. package/dist/cjs/classes/worker.js.map +1 -1
  9. package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +11 -1
  10. package/dist/cjs/commands/includes/removeJobKeys.lua +2 -2
  11. package/dist/cjs/commands/includes/storeJobScheduler.lua +1 -1
  12. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +5 -0
  13. package/dist/cjs/commands/moveToFinished-14.lua +2 -0
  14. package/dist/cjs/commands/moveToWaitingChildren-8.lua +133 -0
  15. package/dist/cjs/commands/removeJob-3.lua +10 -0
  16. package/dist/cjs/scripts/addJobScheduler-10.js +3 -3
  17. package/dist/cjs/scripts/addRepeatableJob-2.js +2 -2
  18. package/dist/cjs/scripts/cleanJobsInSet-3.js +2 -2
  19. package/dist/cjs/scripts/drain-5.js +2 -2
  20. package/dist/cjs/scripts/index.js +1 -1
  21. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +17 -3
  22. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  23. package/dist/cjs/scripts/moveToFinished-14.js +14 -3
  24. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  25. package/dist/cjs/scripts/moveToWaitingChildren-8.js +549 -0
  26. package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -0
  27. package/dist/cjs/scripts/obliterate-2.js +2 -2
  28. package/dist/cjs/scripts/removeChildDependency-1.js +2 -2
  29. package/dist/cjs/scripts/removeJob-3.js +10 -2
  30. package/dist/cjs/scripts/removeJob-3.js.map +1 -1
  31. package/dist/cjs/scripts/removeJobScheduler-3.js +2 -2
  32. package/dist/cjs/scripts/removeRepeatable-3.js +2 -2
  33. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  34. package/dist/cjs/version.js +1 -1
  35. package/dist/esm/classes/job-scheduler.js +3 -0
  36. package/dist/esm/classes/job-scheduler.js.map +1 -1
  37. package/dist/esm/classes/job.js +20 -13
  38. package/dist/esm/classes/job.js.map +1 -1
  39. package/dist/esm/classes/scripts.js +5 -1
  40. package/dist/esm/classes/scripts.js.map +1 -1
  41. package/dist/esm/classes/worker.js +4 -8
  42. package/dist/esm/classes/worker.js.map +1 -1
  43. package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +11 -1
  44. package/dist/esm/commands/includes/removeJobKeys.lua +2 -2
  45. package/dist/esm/commands/includes/storeJobScheduler.lua +1 -1
  46. package/dist/esm/commands/moveStalledJobsToWait-9.lua +5 -0
  47. package/dist/esm/commands/moveToFinished-14.lua +2 -0
  48. package/dist/esm/commands/moveToWaitingChildren-8.lua +133 -0
  49. package/dist/esm/commands/removeJob-3.lua +10 -0
  50. package/dist/esm/scripts/addJobScheduler-10.js +3 -3
  51. package/dist/esm/scripts/addRepeatableJob-2.js +2 -2
  52. package/dist/esm/scripts/cleanJobsInSet-3.js +2 -2
  53. package/dist/esm/scripts/drain-5.js +2 -2
  54. package/dist/esm/scripts/index.d.ts +1 -1
  55. package/dist/esm/scripts/index.js +1 -1
  56. package/dist/esm/scripts/moveStalledJobsToWait-9.js +17 -3
  57. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  58. package/dist/esm/scripts/moveToFinished-14.js +14 -3
  59. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  60. package/dist/esm/scripts/moveToWaitingChildren-8.js +546 -0
  61. package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -0
  62. package/dist/esm/scripts/obliterate-2.js +2 -2
  63. package/dist/esm/scripts/removeChildDependency-1.js +2 -2
  64. package/dist/esm/scripts/removeJob-3.js +10 -2
  65. package/dist/esm/scripts/removeJob-3.js.map +1 -1
  66. package/dist/esm/scripts/removeJobScheduler-3.js +2 -2
  67. package/dist/esm/scripts/removeRepeatable-3.js +2 -2
  68. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  69. package/dist/esm/version.d.ts +1 -1
  70. package/dist/esm/version.js +1 -1
  71. package/package.json +1 -1
  72. package/dist/cjs/commands/moveToWaitingChildren-5.lua +0 -68
  73. package/dist/cjs/scripts/moveToWaitingChildren-5.js +0 -83
  74. package/dist/cjs/scripts/moveToWaitingChildren-5.js.map +0 -1
  75. package/dist/esm/commands/moveToWaitingChildren-5.lua +0 -68
  76. package/dist/esm/scripts/moveToWaitingChildren-5.js +0 -80
  77. package/dist/esm/scripts/moveToWaitingChildren-5.js.map +0 -1
  78. /package/dist/esm/scripts/{moveToWaitingChildren-5.d.ts → moveToWaitingChildren-8.d.ts} +0 -0
@@ -42,5 +42,5 @@ local function storeJobScheduler(schedulerId, schedulerKey, repeatKey, nextMilli
42
42
  table.insert(optionalValues, templateData)
43
43
  end
44
44
 
45
- rcall("HMSET", schedulerKey, "name", opts['name'], unpack(optionalValues))
45
+ rcall("HMSET", schedulerKey, "name", opts['name'], "ic", 1, unpack(optionalValues))
46
46
  end
@@ -98,6 +98,11 @@ if (#stalling > 0) then
98
98
  if rawParentData then
99
99
  if opts['fpof'] then
100
100
  local parentData = cjson.decode(rawParentData)
101
+ -- TODO: need to remove this job from dependencies set in next breaking change
102
+ -- no for now as it would imply a breaking change
103
+ local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
104
+ local unsuccesssfulSet = parentKey .. ":unsuccessful"
105
+ rcall("ZADD", unsuccesssfulSet, timestamp, jobKey)
101
106
  moveParentFromWaitingChildrenToFailed(
102
107
  parentData['queueKey'],
103
108
  parentData['queueKey'] .. ':' .. parentData['id'],
@@ -146,6 +146,8 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
146
146
  end
147
147
  else
148
148
  if opts['fpof'] then
149
+ local unsuccesssfulSet = parentKey .. ":unsuccessful"
150
+ rcall("ZADD", unsuccesssfulSet, timestamp, jobIdKey)
149
151
  moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
150
152
  parentId, jobIdKey,
151
153
  timestamp)
@@ -0,0 +1,133 @@
1
+ --[[
2
+ Moves job from active to waiting children set.
3
+
4
+ Input:
5
+ KEYS[1] active key
6
+ KEYS[2] wait-children key
7
+ KEYS[3] job key
8
+ KEYS[4] job dependencies key
9
+ KEYS[5] job unsuccessful key
10
+ KEYS[6] stalled key
11
+ KEYS[7] failed key
12
+ KEYS[8] events key
13
+
14
+ ARGV[1] token
15
+ ARGV[2] child key
16
+ ARGV[3] timestamp
17
+ ARGV[4] jobId
18
+ ARGV[5] prefix
19
+
20
+ Output:
21
+ 0 - OK
22
+ 1 - There are not pending dependencies.
23
+ -1 - Missing job.
24
+ -2 - Missing lock
25
+ -3 - Job not in active set
26
+ ]]
27
+ local rcall = redis.call
28
+ local activeKey = KEYS[1]
29
+ local waitingChildrenKey = KEYS[2]
30
+ local jobKey = KEYS[3]
31
+ local jobDependenciesKey = KEYS[4]
32
+ local jobUnsuccessfulKey = KEYS[5]
33
+ local stalledKey = KEYS[6]
34
+ local failedKey = KEYS[7]
35
+ local timestamp = ARGV[3]
36
+ local jobId = ARGV[4]
37
+
38
+ --- Includes
39
+ --- @include "includes/moveParentFromWaitingChildrenToFailed"
40
+ --- @include "includes/moveParentToWaitIfNeeded"
41
+ --- @include "includes/removeDeduplicationKeyIfNeeded"
42
+ --- @include "includes/removeJobsOnFail"
43
+ --- @include "includes/removeLock"
44
+
45
+ local function moveToWaitingChildren (activeKey, waitingChildrenKey, jobId,
46
+ timestamp)
47
+ local score = tonumber(timestamp)
48
+
49
+ local numRemovedElements = rcall("LREM", activeKey, -1, jobId)
50
+
51
+ if(numRemovedElements < 1) then
52
+ return -3
53
+ end
54
+
55
+ rcall("ZADD", waitingChildrenKey, score, jobId)
56
+
57
+ return 0
58
+ end
59
+
60
+ if rcall("EXISTS", jobKey) == 1 then
61
+ if rcall("ZCARD", jobUnsuccessfulKey) ~= 0 then
62
+ -- TODO: refactor this logic in an include later
63
+ local jobAttributes = rcall("HMGET", jobKey, "parent", "deid", "opts")
64
+
65
+ removeDeduplicationKeyIfNeeded(ARGV[5], jobAttributes[2])
66
+
67
+ local failedReason = "children are failed"
68
+ rcall("ZADD", failedKey, timestamp, jobId)
69
+ rcall("HSET", jobKey, "finishedOn", timestamp)
70
+ rcall("XADD", KEYS[8], "*", "event", "failed", "jobId", jobId, "failedReason",
71
+ failedReason, "prev", "active")
72
+
73
+ local rawParentData = jobAttributes[1]
74
+ local rawOpts = jobAttributes[3]
75
+ local opts = cjson.decode(rawOpts)
76
+
77
+ if rawParentData ~= false then
78
+ if opts['fpof'] then
79
+ local parentData = cjson.decode(rawParentData)
80
+ local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
81
+ local parentUnsuccesssful = parentKey .. ":unsuccessful"
82
+ rcall("ZADD", parentUnsuccesssful, timestamp, jobKey)
83
+ moveParentFromWaitingChildrenToFailed(
84
+ parentData['queueKey'],
85
+ parentData['queueKey'] .. ':' .. parentData['id'],
86
+ parentData['id'],
87
+ jobKey,
88
+ timestamp
89
+ )
90
+ elseif opts['idof'] or opts['rdof'] then
91
+ local parentData = cjson.decode(rawParentData)
92
+ local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
93
+ local dependenciesSet = parentKey .. ":dependencies"
94
+ if rcall("SREM", dependenciesSet, jobKey) == 1 then
95
+ moveParentToWaitIfNeeded(parentData['queueKey'], dependenciesSet,
96
+ parentKey, parentData['id'], timestamp)
97
+ if opts['idof'] then
98
+ local failedSet = parentKey .. ":failed"
99
+ rcall("HSET", failedSet, jobKey, failedReason)
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ removeJobsOnFail(ARGV[5], failedKey, jobId, opts, timestamp)
106
+
107
+ return 0
108
+ else
109
+ if ARGV[2] ~= "" then
110
+ if rcall("SISMEMBER", jobDependenciesKey, ARGV[2]) ~= 0 then
111
+ local errorCode = removeLock(jobKey, stalledKey, ARGV[1], jobId)
112
+ if errorCode < 0 then
113
+ return errorCode
114
+ end
115
+ return moveToWaitingChildren(activeKey, waitingChildrenKey, jobId, timestamp)
116
+ end
117
+
118
+ return 1
119
+ else
120
+ if rcall("SCARD", jobDependenciesKey) ~= 0 then
121
+ local errorCode = removeLock(jobKey, stalledKey, ARGV[1], jobId)
122
+ if errorCode < 0 then
123
+ return errorCode
124
+ end
125
+ return moveToWaitingChildren(activeKey, waitingChildrenKey, jobId, timestamp)
126
+ end
127
+
128
+ return 1
129
+ end
130
+ end
131
+ end
132
+
133
+ return -1
@@ -65,6 +65,16 @@ local function removeJob(prefix, jobId, parentKey, removeChildren)
65
65
  removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
66
66
  end
67
67
  end
68
+
69
+ local unsuccessful = rcall("ZRANGE", jobKey .. ":unsuccessful", 0, -1)
70
+
71
+ if (#unsuccessful > 0) then
72
+ for i = 1, #unsuccessful, 1 do
73
+ local childJobId = getJobIdFromKey(unsuccessful[i])
74
+ local childJobPrefix = getJobKeyPrefix(unsuccessful[i], childJobId)
75
+ removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
76
+ end
77
+ end
68
78
  end
69
79
 
70
80
  local prev = removeJobFromAnyState(prefix, jobId)
@@ -230,8 +230,8 @@ end
230
230
  Function to remove job keys.
231
231
  ]]
232
232
  local function removeJobKeys(jobKey)
233
- return rcall("DEL", jobKey, jobKey .. ':logs',
234
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
233
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
234
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
235
235
  end
236
236
  --[[
237
237
  Check if this job has a parent. If so we will just remove it from
@@ -393,7 +393,7 @@ local function storeJobScheduler(schedulerId, schedulerKey, repeatKey, nextMilli
393
393
  table.insert(optionalValues, "data")
394
394
  table.insert(optionalValues, templateData)
395
395
  end
396
- rcall("HMSET", schedulerKey, "name", opts['name'], unpack(optionalValues))
396
+ rcall("HMSET", schedulerKey, "name", opts['name'], "ic", 1, unpack(optionalValues))
397
397
  end
398
398
  -- If we are overriding a repeatable job we must delete the delayed job for
399
399
  -- the next iteration.
@@ -45,8 +45,8 @@ end
45
45
  Function to remove job keys.
46
46
  ]]
47
47
  local function removeJobKeys(jobKey)
48
- return rcall("DEL", jobKey, jobKey .. ':logs',
49
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
48
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
49
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
50
50
  end
51
51
  --[[
52
52
  Check if this job has a parent. If so we will just remove it from
@@ -81,8 +81,8 @@ end
81
81
  Function to remove job keys.
82
82
  ]]
83
83
  local function removeJobKeys(jobKey)
84
- return rcall("DEL", jobKey, jobKey .. ':logs',
85
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
84
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
85
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
86
86
  end
87
87
  --[[
88
88
  Check if this job has a parent. If so we will just remove it from
@@ -53,8 +53,8 @@ end
53
53
  Function to remove job keys.
54
54
  ]]
55
55
  local function removeJobKeys(jobKey)
56
- return rcall("DEL", jobKey, jobKey .. ':logs',
57
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
56
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
57
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
58
58
  end
59
59
  --[[
60
60
  Check if this job has a parent. If so we will just remove it from
@@ -30,7 +30,7 @@ tslib_1.__exportStar(require("./moveStalledJobsToWait-9"), exports);
30
30
  tslib_1.__exportStar(require("./moveToActive-11"), exports);
31
31
  tslib_1.__exportStar(require("./moveToDelayed-8"), exports);
32
32
  tslib_1.__exportStar(require("./moveToFinished-14"), exports);
33
- tslib_1.__exportStar(require("./moveToWaitingChildren-5"), exports);
33
+ tslib_1.__exportStar(require("./moveToWaitingChildren-8"), exports);
34
34
  tslib_1.__exportStar(require("./obliterate-2"), exports);
35
35
  tslib_1.__exportStar(require("./paginate-1"), exports);
36
36
  tslib_1.__exportStar(require("./pause-7"), exports);
@@ -213,8 +213,8 @@ end
213
213
  Function to remove job keys.
214
214
  ]]
215
215
  local function removeJobKeys(jobKey)
216
- return rcall("DEL", jobKey, jobKey .. ':logs',
217
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
216
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
217
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
218
218
  end
219
219
  --[[
220
220
  Check if this job has a parent. If so we will just remove it from
@@ -370,13 +370,16 @@ local function moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
370
370
  local parentFailedKey = parentQueueKey .. ":failed"
371
371
  rcall("ZADD", parentFailedKey, timestamp, parentId)
372
372
  local failedReason = "child " .. jobIdKey .. " failed"
373
- rcall("HMSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
373
+ rcall("HSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
374
374
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
375
375
  failedReason, "prev", "waiting-children")
376
376
  local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
377
377
  removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
378
378
  if jobAttributes[1] then
379
379
  local parentData = cjson.decode(jobAttributes[1])
380
+ local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
381
+ local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
382
+ rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
380
383
  if parentData['fpof'] then
381
384
  moveParentFromWaitingChildrenToFailed(
382
385
  parentData['queueKey'],
@@ -438,6 +441,12 @@ local function moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
438
441
  local parentRawOpts = jobAttributes[3]
439
442
  local parentOpts = cjson.decode(parentRawOpts)
440
443
  removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
444
+ else
445
+ local grandParentKey = rcall("HGET", parentKey, "parentKey")
446
+ if grandParentKey then
447
+ local grandParentUnsuccesssfulSet = grandParentKey .. ":unsuccessful"
448
+ rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
449
+ end
441
450
  end
442
451
  end
443
452
  --[[
@@ -519,6 +528,11 @@ if (#stalling > 0) then
519
528
  if rawParentData then
520
529
  if opts['fpof'] then
521
530
  local parentData = cjson.decode(rawParentData)
531
+ -- TODO: need to remove this job from dependencies set in next breaking change
532
+ -- no for now as it would imply a breaking change
533
+ local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
534
+ local unsuccesssfulSet = parentKey .. ":unsuccessful"
535
+ rcall("ZADD", unsuccesssfulSet, timestamp, jobKey)
522
536
  moveParentFromWaitingChildrenToFailed(
523
537
  parentData['queueKey'],
524
538
  parentData['queueKey'] .. ':' .. parentData['id'],
@@ -1 +1 @@
1
- {"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAmkBS,CAAC;AACb,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -308,8 +308,8 @@ end
308
308
  Function to remove job keys.
309
309
  ]]
310
310
  local function removeJobKeys(jobKey)
311
- return rcall("DEL", jobKey, jobKey .. ':logs',
312
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
311
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
312
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
313
313
  end
314
314
  --[[
315
315
  Check if this job has a parent. If so we will just remove it from
@@ -465,13 +465,16 @@ local function moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
465
465
  local parentFailedKey = parentQueueKey .. ":failed"
466
466
  rcall("ZADD", parentFailedKey, timestamp, parentId)
467
467
  local failedReason = "child " .. jobIdKey .. " failed"
468
- rcall("HMSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
468
+ rcall("HSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
469
469
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
470
470
  failedReason, "prev", "waiting-children")
471
471
  local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
472
472
  removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
473
473
  if jobAttributes[1] then
474
474
  local parentData = cjson.decode(jobAttributes[1])
475
+ local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
476
+ local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
477
+ rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
475
478
  if parentData['fpof'] then
476
479
  moveParentFromWaitingChildrenToFailed(
477
480
  parentData['queueKey'],
@@ -533,6 +536,12 @@ local function moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
533
536
  local parentRawOpts = jobAttributes[3]
534
537
  local parentOpts = cjson.decode(parentRawOpts)
535
538
  removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
539
+ else
540
+ local grandParentKey = rcall("HGET", parentKey, "parentKey")
541
+ if grandParentKey then
542
+ local grandParentUnsuccesssfulSet = grandParentKey .. ":unsuccessful"
543
+ rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
544
+ end
536
545
  end
537
546
  end
538
547
  --[[
@@ -722,6 +731,8 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
722
731
  end
723
732
  else
724
733
  if opts['fpof'] then
734
+ local unsuccesssfulSet = parentKey .. ":unsuccessful"
735
+ rcall("ZADD", unsuccesssfulSet, timestamp, jobIdKey)
725
736
  moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
726
737
  parentId, jobIdKey,
727
738
  timestamp)
@@ -1 +1 @@
1
- {"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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