bullmq 5.41.8 → 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 (98) hide show
  1. package/dist/cjs/classes/job-scheduler.js +14 -18
  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 +33 -3
  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/addJobScheduler-10.lua +9 -36
  10. package/dist/cjs/commands/includes/addJobFromScheduler.lua +41 -0
  11. package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +11 -1
  12. package/dist/cjs/commands/includes/removeJobKeys.lua +2 -2
  13. package/dist/cjs/commands/includes/storeJobScheduler.lua +1 -1
  14. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +5 -0
  15. package/dist/cjs/commands/moveToFinished-14.lua +2 -0
  16. package/dist/cjs/commands/moveToWaitingChildren-8.lua +133 -0
  17. package/dist/cjs/commands/removeJob-3.lua +10 -0
  18. package/dist/{esm/commands/updateJobScheduler-7.lua → cjs/commands/updateJobScheduler-11.lua} +28 -21
  19. package/dist/cjs/scripts/addJobScheduler-10.js +80 -70
  20. package/dist/cjs/scripts/addJobScheduler-10.js.map +1 -1
  21. package/dist/cjs/scripts/addRepeatableJob-2.js +2 -2
  22. package/dist/cjs/scripts/cleanJobsInSet-3.js +2 -2
  23. package/dist/cjs/scripts/drain-5.js +2 -2
  24. package/dist/cjs/scripts/index.js +2 -2
  25. package/dist/cjs/scripts/index.js.map +1 -1
  26. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +17 -3
  27. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  28. package/dist/cjs/scripts/moveToFinished-14.js +14 -3
  29. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  30. package/dist/cjs/scripts/moveToWaitingChildren-8.js +549 -0
  31. package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -0
  32. package/dist/cjs/scripts/obliterate-2.js +2 -2
  33. package/dist/cjs/scripts/removeChildDependency-1.js +2 -2
  34. package/dist/cjs/scripts/removeJob-3.js +10 -2
  35. package/dist/cjs/scripts/removeJob-3.js.map +1 -1
  36. package/dist/cjs/scripts/removeJobScheduler-3.js +2 -2
  37. package/dist/cjs/scripts/removeRepeatable-3.js +2 -2
  38. package/dist/cjs/scripts/updateJobScheduler-11.js +246 -0
  39. package/dist/cjs/scripts/updateJobScheduler-11.js.map +1 -0
  40. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  41. package/dist/cjs/version.js +1 -1
  42. package/dist/esm/classes/job-scheduler.js +14 -18
  43. package/dist/esm/classes/job-scheduler.js.map +1 -1
  44. package/dist/esm/classes/job.js +20 -13
  45. package/dist/esm/classes/job.js.map +1 -1
  46. package/dist/esm/classes/scripts.d.ts +1 -1
  47. package/dist/esm/classes/scripts.js +33 -3
  48. package/dist/esm/classes/scripts.js.map +1 -1
  49. package/dist/esm/classes/worker.js +4 -8
  50. package/dist/esm/classes/worker.js.map +1 -1
  51. package/dist/esm/commands/addJobScheduler-10.lua +9 -36
  52. package/dist/esm/commands/includes/addJobFromScheduler.lua +41 -0
  53. package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +11 -1
  54. package/dist/esm/commands/includes/removeJobKeys.lua +2 -2
  55. package/dist/esm/commands/includes/storeJobScheduler.lua +1 -1
  56. package/dist/esm/commands/moveStalledJobsToWait-9.lua +5 -0
  57. package/dist/esm/commands/moveToFinished-14.lua +2 -0
  58. package/dist/esm/commands/moveToWaitingChildren-8.lua +133 -0
  59. package/dist/esm/commands/removeJob-3.lua +10 -0
  60. package/dist/{cjs/commands/updateJobScheduler-7.lua → esm/commands/updateJobScheduler-11.lua} +28 -21
  61. package/dist/esm/scripts/addJobScheduler-10.js +80 -70
  62. package/dist/esm/scripts/addJobScheduler-10.js.map +1 -1
  63. package/dist/esm/scripts/addRepeatableJob-2.js +2 -2
  64. package/dist/esm/scripts/cleanJobsInSet-3.js +2 -2
  65. package/dist/esm/scripts/drain-5.js +2 -2
  66. package/dist/esm/scripts/index.d.ts +2 -2
  67. package/dist/esm/scripts/index.js +2 -2
  68. package/dist/esm/scripts/index.js.map +1 -1
  69. package/dist/esm/scripts/moveStalledJobsToWait-9.js +17 -3
  70. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  71. package/dist/esm/scripts/moveToFinished-14.js +14 -3
  72. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  73. package/dist/esm/scripts/moveToWaitingChildren-8.js +546 -0
  74. package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -0
  75. package/dist/esm/scripts/obliterate-2.js +2 -2
  76. package/dist/esm/scripts/removeChildDependency-1.js +2 -2
  77. package/dist/esm/scripts/removeJob-3.js +10 -2
  78. package/dist/esm/scripts/removeJob-3.js.map +1 -1
  79. package/dist/esm/scripts/removeJobScheduler-3.js +2 -2
  80. package/dist/esm/scripts/removeRepeatable-3.js +2 -2
  81. package/dist/esm/scripts/updateJobScheduler-11.js +243 -0
  82. package/dist/esm/scripts/updateJobScheduler-11.js.map +1 -0
  83. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  84. package/dist/esm/version.d.ts +1 -1
  85. package/dist/esm/version.js +1 -1
  86. package/package.json +1 -1
  87. package/dist/cjs/commands/moveToWaitingChildren-5.lua +0 -68
  88. package/dist/cjs/scripts/moveToWaitingChildren-5.js +0 -83
  89. package/dist/cjs/scripts/moveToWaitingChildren-5.js.map +0 -1
  90. package/dist/cjs/scripts/updateJobScheduler-7.js +0 -144
  91. package/dist/cjs/scripts/updateJobScheduler-7.js.map +0 -1
  92. package/dist/esm/commands/moveToWaitingChildren-5.lua +0 -68
  93. package/dist/esm/scripts/moveToWaitingChildren-5.js +0 -80
  94. package/dist/esm/scripts/moveToWaitingChildren-5.js.map +0 -1
  95. package/dist/esm/scripts/updateJobScheduler-7.js +0 -141
  96. package/dist/esm/scripts/updateJobScheduler-7.js.map +0 -1
  97. /package/dist/esm/scripts/{moveToWaitingChildren-5.d.ts → moveToWaitingChildren-8.d.ts} +0 -0
  98. /package/dist/esm/scripts/{updateJobScheduler-7.d.ts → updateJobScheduler-11.d.ts} +0 -0
@@ -31,12 +31,19 @@ const content = `--[[
31
31
  local rcall = redis.call
32
32
  local repeatKey = KEYS[1]
33
33
  local delayedKey = KEYS[2]
34
+ local waitKey = KEYS[3]
35
+ local pausedKey = KEYS[4]
36
+ local metaKey = KEYS[5]
34
37
  local prioritizedKey = KEYS[6]
35
38
  local nextMillis = ARGV[1]
36
39
  local jobSchedulerId = ARGV[3]
37
40
  local templateOpts = cmsgpack.unpack(ARGV[5])
38
41
  local prefixKey = ARGV[8]
39
42
  -- Includes
43
+ --[[
44
+ Add delay marker if needed.
45
+ ]]
46
+ -- Includes
40
47
  --[[
41
48
  Adds a delayed job to the queue by doing the following:
42
49
  - Creates a new job key with the job data.
@@ -126,6 +133,71 @@ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, pr
126
133
  rcall("ZADD", prioritizedKey, score, jobId)
127
134
  addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
128
135
  end
136
+ --[[
137
+ Function to check for the meta.paused key to decide if we are paused or not
138
+ (since an empty list and !EXISTS are not really the same).
139
+ ]]
140
+ local function isQueuePaused(queueMetaKey)
141
+ return rcall("HEXISTS", queueMetaKey, "paused") == 1
142
+ end
143
+ --[[
144
+ Function to store a job
145
+ ]]
146
+ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
147
+ parentKey, parentData, repeatJobKey)
148
+ local jsonOpts = cjson.encode(opts)
149
+ local delay = opts['delay'] or 0
150
+ local priority = opts['priority'] or 0
151
+ local debounceId = opts['de'] and opts['de']['id']
152
+ local optionalValues = {}
153
+ if parentKey ~= nil then
154
+ table.insert(optionalValues, "parentKey")
155
+ table.insert(optionalValues, parentKey)
156
+ table.insert(optionalValues, "parent")
157
+ table.insert(optionalValues, parentData)
158
+ end
159
+ if repeatJobKey ~= nil then
160
+ table.insert(optionalValues, "rjk")
161
+ table.insert(optionalValues, repeatJobKey)
162
+ end
163
+ if debounceId then
164
+ table.insert(optionalValues, "deid")
165
+ table.insert(optionalValues, debounceId)
166
+ end
167
+ rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,
168
+ "timestamp", timestamp, "delay", delay, "priority", priority,
169
+ unpack(optionalValues))
170
+ rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)
171
+ return delay, priority
172
+ end
173
+ local function addJobFromScheduler(jobKey, jobId, rawOpts, waitKey, pausedKey, metaKey, prioritizedKey,
174
+ priorityCounter, delayedKey, markerKey, eventsKey, name, maxEvents, timestamp, data, jobSchedulerId)
175
+ local opts = cmsgpack.unpack(rawOpts)
176
+ local delay, priority = storeJob(eventsKey, jobKey, jobId, name, data,
177
+ opts, timestamp, nil, nil, jobSchedulerId)
178
+ if delay ~= 0 then
179
+ addDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, markerKey, delay)
180
+ else
181
+ local isPaused = isQueuePaused(metaKey)
182
+ -- Standard or priority add
183
+ if priority == 0 then
184
+ if isPaused then
185
+ -- LIFO or FIFO
186
+ local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'
187
+ rcall(pushCmd, pausedKey, jobId)
188
+ else
189
+ -- LIFO or FIFO
190
+ local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'
191
+ rcall(pushCmd, waitKey, jobId)
192
+ end
193
+ else
194
+ -- Priority add
195
+ addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounter, isPaused)
196
+ end
197
+ -- Emit waiting event
198
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting", "jobId", jobId)
199
+ end
200
+ end
129
201
  --[[
130
202
  Function to get max events value or set by default 10000.
131
203
  ]]
@@ -137,13 +209,6 @@ local function getOrSetMaxEvents(metaKey)
137
209
  end
138
210
  return maxEvents
139
211
  end
140
- --[[
141
- Function to check for the meta.paused key to decide if we are paused or not
142
- (since an empty list and !EXISTS are not really the same).
143
- ]]
144
- local function isQueuePaused(queueMetaKey)
145
- return rcall("HEXISTS", queueMetaKey, "paused") == 1
146
- end
147
212
  --[[
148
213
  Function to remove job.
149
214
  ]]
@@ -162,8 +227,8 @@ end
162
227
  Function to remove job keys.
163
228
  ]]
164
229
  local function removeJobKeys(jobKey)
165
- return rcall("DEL", jobKey, jobKey .. ':logs',
166
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
230
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
231
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
167
232
  end
168
233
  --[[
169
234
  Check if this job has a parent. If so we will just remove it from
@@ -289,36 +354,6 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
289
354
  end
290
355
  removeJobKeys(jobKey)
291
356
  end
292
- --[[
293
- Function to store a job
294
- ]]
295
- local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
296
- parentKey, parentData, repeatJobKey)
297
- local jsonOpts = cjson.encode(opts)
298
- local delay = opts['delay'] or 0
299
- local priority = opts['priority'] or 0
300
- local debounceId = opts['de'] and opts['de']['id']
301
- local optionalValues = {}
302
- if parentKey ~= nil then
303
- table.insert(optionalValues, "parentKey")
304
- table.insert(optionalValues, parentKey)
305
- table.insert(optionalValues, "parent")
306
- table.insert(optionalValues, parentData)
307
- end
308
- if repeatJobKey ~= nil then
309
- table.insert(optionalValues, "rjk")
310
- table.insert(optionalValues, repeatJobKey)
311
- end
312
- if debounceId then
313
- table.insert(optionalValues, "deid")
314
- table.insert(optionalValues, debounceId)
315
- end
316
- rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,
317
- "timestamp", timestamp, "delay", delay, "priority", priority,
318
- unpack(optionalValues))
319
- rcall("XADD", eventsKey, "*", "event", "added", "jobId", jobId, "name", name)
320
- return delay, priority
321
- end
322
357
  --[[
323
358
  Function to store a job scheduler
324
359
  ]]
@@ -355,7 +390,7 @@ local function storeJobScheduler(schedulerId, schedulerKey, repeatKey, nextMilli
355
390
  table.insert(optionalValues, "data")
356
391
  table.insert(optionalValues, templateData)
357
392
  end
358
- rcall("HMSET", schedulerKey, "name", opts['name'], unpack(optionalValues))
393
+ rcall("HMSET", schedulerKey, "name", opts['name'], "ic", 1, unpack(optionalValues))
359
394
  end
360
395
  -- If we are overriding a repeatable job we must delete the delayed job for
361
396
  -- the next iteration.
@@ -373,12 +408,12 @@ if prevMillis ~= false then
373
408
  removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
374
409
  rcall("ZREM", prioritizedKey, currentJobId)
375
410
  else
376
- if isQueuePaused(KEYS[5]) then
377
- if rcall("LREM", KEYS[4], 1, currentJobId) > 0 then
411
+ if isQueuePaused(metaKey) then
412
+ if rcall("LREM", pausedKey, 1, currentJobId) > 0 then
378
413
  removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
379
414
  end
380
415
  else
381
- if rcall("LREM", KEYS[3], 1, currentJobId) > 0 then
416
+ if rcall("LREM", waitKey, 1, currentJobId) > 0 then
382
417
  removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
383
418
  end
384
419
  end
@@ -389,35 +424,10 @@ local schedulerOpts = cmsgpack.unpack(ARGV[2])
389
424
  storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)
390
425
  if rcall("EXISTS", nextDelayedJobKey) ~= 1 then
391
426
  local eventsKey = KEYS[9]
392
- local metaKey = KEYS[5]
393
427
  local maxEvents = getOrSetMaxEvents(metaKey)
394
428
  rcall("INCR", KEYS[8])
395
- local delayedOpts = cmsgpack.unpack(ARGV[6])
396
- local delay, priority = storeJob(eventsKey, nextDelayedJobKey, nextDelayedJobId, schedulerOpts['name'], ARGV[4],
397
- delayedOpts, ARGV[7], nil, nil, jobSchedulerId)
398
- if delay ~= 0 then
399
- addDelayedJob(nextDelayedJobId, delayedKey, eventsKey,
400
- ARGV[7], maxEvents, KEYS[7], delay)
401
- else
402
- local isPaused = isQueuePaused(KEYS[5])
403
- -- Standard or priority add
404
- if priority == 0 then
405
- if isPaused then
406
- -- LIFO or FIFO
407
- local pushCmd = delayedOpts['lifo'] and 'RPUSH' or 'LPUSH'
408
- rcall(pushCmd, KEYS[4], nextDelayedJobId)
409
- else
410
- -- LIFO or FIFO
411
- local pushCmd = delayedOpts['lifo'] and 'RPUSH' or 'LPUSH'
412
- rcall(pushCmd, KEYS[3], nextDelayedJobId)
413
- end
414
- else
415
- -- Priority add
416
- addJobWithPriority(KEYS[7], KEYS[6], priority, nextDelayedJobId, KEYS[10], isPaused)
417
- end
418
- -- Emit waiting event
419
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting", "jobId", nextDelayedJobId)
420
- end
429
+ addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey, metaKey, prioritizedKey,
430
+ KEYS[10], delayedKey, KEYS[7], eventsKey, schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
421
431
  if ARGV[9] ~= "" then
422
432
  rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
423
433
  end
@@ -1 +1 @@
1
- {"version":3,"file":"addJobScheduler-10.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-10.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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
@@ -27,7 +27,7 @@ export * from './moveStalledJobsToWait-9';
27
27
  export * from './moveToActive-11';
28
28
  export * from './moveToDelayed-8';
29
29
  export * from './moveToFinished-14';
30
- export * from './moveToWaitingChildren-5';
30
+ export * from './moveToWaitingChildren-8';
31
31
  export * from './obliterate-2';
32
32
  export * from './paginate-1';
33
33
  export * from './pause-7';
@@ -41,6 +41,6 @@ export * from './reprocessJob-8';
41
41
  export * from './retryJob-11';
42
42
  export * from './saveStacktrace-1';
43
43
  export * from './updateData-1';
44
- export * from './updateJobScheduler-7';
44
+ export * from './updateJobScheduler-11';
45
45
  export * from './updateProgress-3';
46
46
  export * from './updateRepeatableJobMillis-1';
@@ -27,7 +27,7 @@ export * from './moveStalledJobsToWait-9';
27
27
  export * from './moveToActive-11';
28
28
  export * from './moveToDelayed-8';
29
29
  export * from './moveToFinished-14';
30
- export * from './moveToWaitingChildren-5';
30
+ export * from './moveToWaitingChildren-8';
31
31
  export * from './obliterate-2';
32
32
  export * from './paginate-1';
33
33
  export * from './pause-7';
@@ -41,7 +41,7 @@ export * from './reprocessJob-8';
41
41
  export * from './retryJob-11';
42
42
  export * from './saveStacktrace-1';
43
43
  export * from './updateData-1';
44
- export * from './updateJobScheduler-7';
44
+ export * from './updateJobScheduler-11';
45
45
  export * from './updateProgress-3';
46
46
  export * from './updateRepeatableJobMillis-1';
47
47
  //# sourceMappingURL=index.js.map
@@ -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,CAA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AAC;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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAqjBS,CAAC;AAC1B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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