bullmq 5.41.9 → 5.43.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 (89) 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 +35 -36
  4. package/dist/cjs/classes/job.js.map +1 -1
  5. package/dist/cjs/classes/scripts.js +22 -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/getDependencyCounts-4.lua +31 -0
  10. package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +11 -1
  11. package/dist/cjs/commands/includes/removeJobKeys.lua +2 -2
  12. package/dist/cjs/commands/includes/storeJobScheduler.lua +1 -1
  13. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +5 -0
  14. package/dist/cjs/commands/moveToFinished-14.lua +2 -0
  15. package/dist/cjs/commands/moveToWaitingChildren-8.lua +133 -0
  16. package/dist/cjs/commands/removeJob-3.lua +10 -0
  17. package/dist/cjs/scripts/addJobScheduler-10.js +3 -3
  18. package/dist/cjs/scripts/addRepeatableJob-2.js +2 -2
  19. package/dist/cjs/scripts/cleanJobsInSet-3.js +2 -2
  20. package/dist/cjs/scripts/drain-5.js +2 -2
  21. package/dist/cjs/scripts/getDependencyCounts-4.js +37 -0
  22. package/dist/cjs/scripts/getDependencyCounts-4.js.map +1 -0
  23. package/dist/cjs/scripts/index.js +2 -1
  24. package/dist/cjs/scripts/index.js.map +1 -1
  25. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +17 -3
  26. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  27. package/dist/cjs/scripts/moveToFinished-14.js +14 -3
  28. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  29. package/dist/cjs/scripts/moveToWaitingChildren-8.js +549 -0
  30. package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -0
  31. package/dist/cjs/scripts/obliterate-2.js +2 -2
  32. package/dist/cjs/scripts/removeChildDependency-1.js +2 -2
  33. package/dist/cjs/scripts/removeJob-3.js +10 -2
  34. package/dist/cjs/scripts/removeJob-3.js.map +1 -1
  35. package/dist/cjs/scripts/removeJobScheduler-3.js +2 -2
  36. package/dist/cjs/scripts/removeRepeatable-3.js +2 -2
  37. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  38. package/dist/cjs/version.js +1 -1
  39. package/dist/esm/classes/job-scheduler.js +3 -0
  40. package/dist/esm/classes/job-scheduler.js.map +1 -1
  41. package/dist/esm/classes/job.d.ts +5 -1
  42. package/dist/esm/classes/job.js +35 -36
  43. package/dist/esm/classes/job.js.map +1 -1
  44. package/dist/esm/classes/scripts.d.ts +2 -0
  45. package/dist/esm/classes/scripts.js +22 -1
  46. package/dist/esm/classes/scripts.js.map +1 -1
  47. package/dist/esm/classes/worker.js +4 -8
  48. package/dist/esm/classes/worker.js.map +1 -1
  49. package/dist/esm/commands/getDependencyCounts-4.lua +31 -0
  50. package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +11 -1
  51. package/dist/esm/commands/includes/removeJobKeys.lua +2 -2
  52. package/dist/esm/commands/includes/storeJobScheduler.lua +1 -1
  53. package/dist/esm/commands/moveStalledJobsToWait-9.lua +5 -0
  54. package/dist/esm/commands/moveToFinished-14.lua +2 -0
  55. package/dist/esm/commands/moveToWaitingChildren-8.lua +133 -0
  56. package/dist/esm/commands/removeJob-3.lua +10 -0
  57. package/dist/esm/scripts/addJobScheduler-10.js +3 -3
  58. package/dist/esm/scripts/addRepeatableJob-2.js +2 -2
  59. package/dist/esm/scripts/cleanJobsInSet-3.js +2 -2
  60. package/dist/esm/scripts/drain-5.js +2 -2
  61. package/dist/esm/scripts/getDependencyCounts-4.d.ts +5 -0
  62. package/dist/esm/scripts/getDependencyCounts-4.js +34 -0
  63. package/dist/esm/scripts/getDependencyCounts-4.js.map +1 -0
  64. package/dist/esm/scripts/index.d.ts +2 -1
  65. package/dist/esm/scripts/index.js +2 -1
  66. package/dist/esm/scripts/index.js.map +1 -1
  67. package/dist/esm/scripts/moveStalledJobsToWait-9.js +17 -3
  68. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  69. package/dist/esm/scripts/moveToFinished-14.js +14 -3
  70. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  71. package/dist/esm/scripts/moveToWaitingChildren-8.js +546 -0
  72. package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -0
  73. package/dist/esm/scripts/obliterate-2.js +2 -2
  74. package/dist/esm/scripts/removeChildDependency-1.js +2 -2
  75. package/dist/esm/scripts/removeJob-3.js +10 -2
  76. package/dist/esm/scripts/removeJob-3.js.map +1 -1
  77. package/dist/esm/scripts/removeJobScheduler-3.js +2 -2
  78. package/dist/esm/scripts/removeRepeatable-3.js +2 -2
  79. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  80. package/dist/esm/version.d.ts +1 -1
  81. package/dist/esm/version.js +1 -1
  82. package/package.json +1 -1
  83. package/dist/cjs/commands/moveToWaitingChildren-5.lua +0 -68
  84. package/dist/cjs/scripts/moveToWaitingChildren-5.js +0 -83
  85. package/dist/cjs/scripts/moveToWaitingChildren-5.js.map +0 -1
  86. package/dist/esm/commands/moveToWaitingChildren-5.lua +0 -68
  87. package/dist/esm/scripts/moveToWaitingChildren-5.js +0 -80
  88. package/dist/esm/scripts/moveToWaitingChildren-5.js.map +0 -1
  89. /package/dist/esm/scripts/{moveToWaitingChildren-5.d.ts → moveToWaitingChildren-8.d.ts} +0 -0
@@ -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)
@@ -227,8 +227,8 @@ end
227
227
  Function to remove job keys.
228
228
  ]]
229
229
  local function removeJobKeys(jobKey)
230
- return rcall("DEL", jobKey, jobKey .. ':logs',
231
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
230
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
231
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
232
232
  end
233
233
  --[[
234
234
  Check if this job has a parent. If so we will just remove it from
@@ -390,7 +390,7 @@ local function storeJobScheduler(schedulerId, schedulerKey, repeatKey, nextMilli
390
390
  table.insert(optionalValues, "data")
391
391
  table.insert(optionalValues, templateData)
392
392
  end
393
- rcall("HMSET", schedulerKey, "name", opts['name'], unpack(optionalValues))
393
+ rcall("HMSET", schedulerKey, "name", opts['name'], "ic", 1, unpack(optionalValues))
394
394
  end
395
395
  -- If we are overriding a repeatable job we must delete the delayed job for
396
396
  -- the next iteration.
@@ -42,8 +42,8 @@ end
42
42
  Function to remove job keys.
43
43
  ]]
44
44
  local function removeJobKeys(jobKey)
45
- return rcall("DEL", jobKey, jobKey .. ':logs',
46
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
45
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
46
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
47
47
  end
48
48
  --[[
49
49
  Check if this job has a parent. If so we will just remove it from
@@ -78,8 +78,8 @@ end
78
78
  Function to remove job keys.
79
79
  ]]
80
80
  local function removeJobKeys(jobKey)
81
- return rcall("DEL", jobKey, jobKey .. ':logs',
82
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
81
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
82
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
83
83
  end
84
84
  --[[
85
85
  Check if this job has a parent. If so we will just remove it from
@@ -50,8 +50,8 @@ end
50
50
  Function to remove job keys.
51
51
  ]]
52
52
  local function removeJobKeys(jobKey)
53
- return rcall("DEL", jobKey, jobKey .. ':logs',
54
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
53
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
54
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
55
55
  end
56
56
  --[[
57
57
  Check if this job has a parent. If so we will just remove it from
@@ -0,0 +1,5 @@
1
+ export declare const getDependencyCounts: {
2
+ name: string;
3
+ content: string;
4
+ keys: number;
5
+ };
@@ -0,0 +1,34 @@
1
+ const content = `--[[
2
+ Get counts per child states
3
+ Input:
4
+ KEYS[1] processed key
5
+ KEYS[2] unprocessed key
6
+ KEYS[3] ignored key
7
+ KEYS[4] failed key
8
+ ARGV[1...] types
9
+ ]]
10
+ local rcall = redis.call;
11
+ local processedKey = KEYS[1]
12
+ local unprocessedKey = KEYS[2]
13
+ local ignoredKey = KEYS[3]
14
+ local failedKey = KEYS[4]
15
+ local results = {}
16
+ for i = 1, #ARGV do
17
+ if ARGV[i] == "processed" then
18
+ results[#results+1] = rcall("HLEN", processedKey)
19
+ elseif ARGV[i] == "unprocessed" then
20
+ results[#results+1] = rcall("SCARD", unprocessedKey)
21
+ elseif ARGV[i] == "ignored" then
22
+ results[#results+1] = rcall("HLEN", ignoredKey)
23
+ else
24
+ results[#results+1] = rcall("ZCARD", failedKey)
25
+ end
26
+ end
27
+ return results
28
+ `;
29
+ export const getDependencyCounts = {
30
+ name: 'getDependencyCounts',
31
+ content,
32
+ keys: 4,
33
+ };
34
+ //# sourceMappingURL=getDependencyCounts-4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDependencyCounts-4.js","sourceRoot":"","sources":["../../../src/scripts/getDependencyCounts-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Bf,CAAC;AACF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,qBAAqB;IAC3B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -13,6 +13,7 @@ export * from './extendLock-2';
13
13
  export * from './extendLocks-1';
14
14
  export * from './getCounts-1';
15
15
  export * from './getCountsPerPriority-4';
16
+ export * from './getDependencyCounts-4';
16
17
  export * from './getJobScheduler-1';
17
18
  export * from './getRanges-1';
18
19
  export * from './getRateLimitTtl-1';
@@ -27,7 +28,7 @@ export * from './moveStalledJobsToWait-9';
27
28
  export * from './moveToActive-11';
28
29
  export * from './moveToDelayed-8';
29
30
  export * from './moveToFinished-14';
30
- export * from './moveToWaitingChildren-5';
31
+ export * from './moveToWaitingChildren-8';
31
32
  export * from './obliterate-2';
32
33
  export * from './paginate-1';
33
34
  export * from './pause-7';
@@ -13,6 +13,7 @@ export * from './extendLock-2';
13
13
  export * from './extendLocks-1';
14
14
  export * from './getCounts-1';
15
15
  export * from './getCountsPerPriority-4';
16
+ export * from './getDependencyCounts-4';
16
17
  export * from './getJobScheduler-1';
17
18
  export * from './getRanges-1';
18
19
  export * from './getRateLimitTtl-1';
@@ -27,7 +28,7 @@ export * from './moveStalledJobsToWait-9';
27
28
  export * from './moveToActive-11';
28
29
  export * from './moveToDelayed-8';
29
30
  export * from './moveToFinished-14';
30
- export * from './moveToWaitingChildren-5';
31
+ export * from './moveToWaitingChildren-8';
31
32
  export * from './obliterate-2';
32
33
  export * from './paginate-1';
33
34
  export * from './pause-7';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,c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cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC"}
@@ -210,8 +210,8 @@ end
210
210
  Function to remove job keys.
211
211
  ]]
212
212
  local function removeJobKeys(jobKey)
213
- return rcall("DEL", jobKey, jobKey .. ':logs',
214
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
213
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
214
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
215
215
  end
216
216
  --[[
217
217
  Check if this job has a parent. If so we will just remove it from
@@ -367,13 +367,16 @@ local function moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
367
367
  local parentFailedKey = parentQueueKey .. ":failed"
368
368
  rcall("ZADD", parentFailedKey, timestamp, parentId)
369
369
  local failedReason = "child " .. jobIdKey .. " failed"
370
- rcall("HMSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
370
+ rcall("HSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
371
371
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
372
372
  failedReason, "prev", "waiting-children")
373
373
  local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
374
374
  removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
375
375
  if jobAttributes[1] then
376
376
  local parentData = cjson.decode(jobAttributes[1])
377
+ local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
378
+ local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
379
+ rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
377
380
  if parentData['fpof'] then
378
381
  moveParentFromWaitingChildrenToFailed(
379
382
  parentData['queueKey'],
@@ -435,6 +438,12 @@ local function moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
435
438
  local parentRawOpts = jobAttributes[3]
436
439
  local parentOpts = cjson.decode(parentRawOpts)
437
440
  removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
441
+ else
442
+ local grandParentKey = rcall("HGET", parentKey, "parentKey")
443
+ if grandParentKey then
444
+ local grandParentUnsuccesssfulSet = grandParentKey .. ":unsuccessful"
445
+ rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
446
+ end
438
447
  end
439
448
  end
440
449
  --[[
@@ -516,6 +525,11 @@ if (#stalling > 0) then
516
525
  if rawParentData then
517
526
  if opts['fpof'] then
518
527
  local parentData = cjson.decode(rawParentData)
528
+ -- TODO: need to remove this job from dependencies set in next breaking change
529
+ -- no for now as it would imply a breaking change
530
+ local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
531
+ local unsuccesssfulSet = parentKey .. ":unsuccessful"
532
+ rcall("ZADD", unsuccesssfulSet, timestamp, jobKey)
519
533
  moveParentFromWaitingChildrenToFailed(
520
534
  parentData['queueKey'],
521
535
  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;AAC1B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -305,8 +305,8 @@ end
305
305
  Function to remove job keys.
306
306
  ]]
307
307
  local function removeJobKeys(jobKey)
308
- return rcall("DEL", jobKey, jobKey .. ':logs',
309
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
308
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
309
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
310
310
  end
311
311
  --[[
312
312
  Check if this job has a parent. If so we will just remove it from
@@ -462,13 +462,16 @@ local function moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
462
462
  local parentFailedKey = parentQueueKey .. ":failed"
463
463
  rcall("ZADD", parentFailedKey, timestamp, parentId)
464
464
  local failedReason = "child " .. jobIdKey .. " failed"
465
- rcall("HMSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
465
+ rcall("HSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
466
466
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
467
467
  failedReason, "prev", "waiting-children")
468
468
  local jobAttributes = rcall("HMGET", parentKey, "parent", "deid", "opts")
469
469
  removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
470
470
  if jobAttributes[1] then
471
471
  local parentData = cjson.decode(jobAttributes[1])
472
+ local grandParentKey = parentData['queueKey'] .. ':' .. parentData['id']
473
+ local grandParentUnsuccesssful = grandParentKey .. ":unsuccessful"
474
+ rcall("ZADD", grandParentUnsuccesssful, timestamp, parentKey)
472
475
  if parentData['fpof'] then
473
476
  moveParentFromWaitingChildrenToFailed(
474
477
  parentData['queueKey'],
@@ -530,6 +533,12 @@ local function moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
530
533
  local parentRawOpts = jobAttributes[3]
531
534
  local parentOpts = cjson.decode(parentRawOpts)
532
535
  removeJobsOnFail(parentQueuePrefix, parentFailedKey, parentId, parentOpts, timestamp)
536
+ else
537
+ local grandParentKey = rcall("HGET", parentKey, "parentKey")
538
+ if grandParentKey then
539
+ local grandParentUnsuccesssfulSet = grandParentKey .. ":unsuccessful"
540
+ rcall("ZADD", grandParentUnsuccesssfulSet, timestamp, parentKey)
541
+ end
533
542
  end
534
543
  end
535
544
  --[[
@@ -719,6 +728,8 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
719
728
  end
720
729
  else
721
730
  if opts['fpof'] then
731
+ local unsuccesssfulSet = parentKey .. ":unsuccessful"
732
+ rcall("ZADD", unsuccesssfulSet, timestamp, jobIdKey)
722
733
  moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
723
734
  parentId, jobIdKey,
724
735
  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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