bullmq 5.49.2 → 5.51.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 (100) hide show
  1. package/dist/cjs/classes/flow-producer.js +7 -3
  2. package/dist/cjs/classes/flow-producer.js.map +1 -1
  3. package/dist/cjs/classes/job.js +80 -40
  4. package/dist/cjs/classes/job.js.map +1 -1
  5. package/dist/cjs/classes/queue.js +0 -1
  6. package/dist/cjs/classes/queue.js.map +1 -1
  7. package/dist/cjs/commands/addJobScheduler-11.lua +40 -45
  8. package/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +0 -1
  9. package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
  10. package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
  11. package/dist/cjs/commands/includes/removeJob.lua +2 -2
  12. package/dist/cjs/commands/includes/removeJobWithChildren.lua +2 -2
  13. package/dist/cjs/commands/includes/storeJob.lua +1 -1
  14. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +2 -2
  15. package/dist/cjs/commands/moveToFinished-14.lua +2 -2
  16. package/dist/cjs/commands/moveToWaitingChildren-8.lua +2 -2
  17. package/dist/cjs/commands/updateJobScheduler-12.lua +1 -1
  18. package/dist/cjs/scripts/addDelayedJob-6.js +1 -1
  19. package/dist/cjs/scripts/addJobScheduler-11.js +44 -44
  20. package/dist/cjs/scripts/addParentJob-4.js +1 -1
  21. package/dist/cjs/scripts/addPrioritizedJob-8.js +1 -1
  22. package/dist/cjs/scripts/addRepeatableJob-2.js +9 -4
  23. package/dist/cjs/scripts/addRepeatableJob-2.js.map +1 -1
  24. package/dist/cjs/scripts/addStandardJob-8.js +1 -1
  25. package/dist/cjs/scripts/cleanJobsInSet-3.js +9 -4
  26. package/dist/cjs/scripts/cleanJobsInSet-3.js.map +1 -1
  27. package/dist/cjs/scripts/drain-5.js +9 -4
  28. package/dist/cjs/scripts/drain-5.js.map +1 -1
  29. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +30 -17
  30. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  31. package/dist/cjs/scripts/moveToFinished-14.js +30 -17
  32. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  33. package/dist/cjs/scripts/moveToWaitingChildren-8.js +30 -17
  34. package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -1
  35. package/dist/cjs/scripts/obliterate-2.js +9 -4
  36. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  37. package/dist/cjs/scripts/removeJob-3.js +9 -4
  38. package/dist/cjs/scripts/removeJob-3.js.map +1 -1
  39. package/dist/cjs/scripts/removeUnprocessedChildren-2.js +9 -4
  40. package/dist/cjs/scripts/removeUnprocessedChildren-2.js.map +1 -1
  41. package/dist/cjs/scripts/updateJobScheduler-12.js +2 -2
  42. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  43. package/dist/cjs/utils.js +11 -1
  44. package/dist/cjs/utils.js.map +1 -1
  45. package/dist/cjs/version.js +1 -1
  46. package/dist/esm/classes/flow-producer.js +7 -3
  47. package/dist/esm/classes/flow-producer.js.map +1 -1
  48. package/dist/esm/classes/job.d.ts +21 -6
  49. package/dist/esm/classes/job.js +81 -41
  50. package/dist/esm/classes/job.js.map +1 -1
  51. package/dist/esm/classes/queue.d.ts +0 -1
  52. package/dist/esm/classes/queue.js +0 -1
  53. package/dist/esm/classes/queue.js.map +1 -1
  54. package/dist/esm/commands/addJobScheduler-11.lua +40 -45
  55. package/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +0 -1
  56. package/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
  57. package/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
  58. package/dist/esm/commands/includes/removeJob.lua +2 -2
  59. package/dist/esm/commands/includes/removeJobWithChildren.lua +2 -2
  60. package/dist/esm/commands/includes/storeJob.lua +1 -1
  61. package/dist/esm/commands/moveStalledJobsToWait-9.lua +2 -2
  62. package/dist/esm/commands/moveToFinished-14.lua +2 -2
  63. package/dist/esm/commands/moveToWaitingChildren-8.lua +2 -2
  64. package/dist/esm/commands/updateJobScheduler-12.lua +1 -1
  65. package/dist/esm/interfaces/minimal-job.d.ts +22 -8
  66. package/dist/esm/scripts/addDelayedJob-6.js +1 -1
  67. package/dist/esm/scripts/addJobScheduler-11.js +44 -44
  68. package/dist/esm/scripts/addParentJob-4.js +1 -1
  69. package/dist/esm/scripts/addPrioritizedJob-8.js +1 -1
  70. package/dist/esm/scripts/addRepeatableJob-2.js +9 -4
  71. package/dist/esm/scripts/addRepeatableJob-2.js.map +1 -1
  72. package/dist/esm/scripts/addStandardJob-8.js +1 -1
  73. package/dist/esm/scripts/cleanJobsInSet-3.js +9 -4
  74. package/dist/esm/scripts/cleanJobsInSet-3.js.map +1 -1
  75. package/dist/esm/scripts/drain-5.js +9 -4
  76. package/dist/esm/scripts/drain-5.js.map +1 -1
  77. package/dist/esm/scripts/moveStalledJobsToWait-9.js +30 -17
  78. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  79. package/dist/esm/scripts/moveToFinished-14.js +30 -17
  80. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  81. package/dist/esm/scripts/moveToWaitingChildren-8.js +30 -17
  82. package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -1
  83. package/dist/esm/scripts/obliterate-2.js +9 -4
  84. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  85. package/dist/esm/scripts/removeJob-3.js +9 -4
  86. package/dist/esm/scripts/removeJob-3.js.map +1 -1
  87. package/dist/esm/scripts/removeUnprocessedChildren-2.js +9 -4
  88. package/dist/esm/scripts/removeUnprocessedChildren-2.js.map +1 -1
  89. package/dist/esm/scripts/updateJobScheduler-12.js +2 -2
  90. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  91. package/dist/esm/utils.d.ts +17 -0
  92. package/dist/esm/utils.js +10 -0
  93. package/dist/esm/utils.js.map +1 -1
  94. package/dist/esm/version.d.ts +1 -1
  95. package/dist/esm/version.js +1 -1
  96. package/package.json +1 -1
  97. package/dist/cjs/commands/includes/removeDeduplicationKey.lua +0 -11
  98. package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
  99. package/dist/esm/commands/includes/removeDeduplicationKey.lua +0 -11
  100. package/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
@@ -194,18 +194,6 @@ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDep
194
194
  moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
195
195
  end
196
196
  end
197
- --[[
198
- Function to remove deduplication key if needed.
199
- ]]
200
- local function removeDeduplicationKeyIfNeeded(prefixKey, deduplicationId)
201
- if deduplicationId then
202
- local deduplicationKey = prefixKey .. "de:" .. deduplicationId
203
- local pttl = rcall("PTTL", deduplicationKey)
204
- if pttl == 0 or pttl == -1 then
205
- rcall("DEL", deduplicationKey)
206
- end
207
- end
208
- end
209
197
  --[[
210
198
  Functions to remove jobs when removeOnFail option is provided.
211
199
  ]]
@@ -215,13 +203,18 @@ end
215
203
  ]]
216
204
  -- Includes
217
205
  --[[
218
- Function to remove deduplication key.
206
+ Function to remove deduplication key if needed
207
+ when a job is being removed.
219
208
  ]]
220
- local function removeDeduplicationKey(prefixKey, jobKey)
209
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
210
+ jobKey, jobId)
221
211
  local deduplicationId = rcall("HGET", jobKey, "deid")
222
212
  if deduplicationId then
223
213
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
224
- rcall("DEL", deduplicationKey)
214
+ local currentJobId = rcall('GET', deduplicationKey)
215
+ if currentJobId and currentJobId == jobId then
216
+ return rcall("DEL", deduplicationKey)
217
+ end
225
218
  end
226
219
  end
227
220
  --[[
@@ -323,7 +316,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
323
316
  local jobKey = baseKey .. jobId
324
317
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
325
318
  if shouldRemoveDeduplicationKey then
326
- removeDeduplicationKey(baseKey, jobKey)
319
+ removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
327
320
  end
328
321
  removeJobKeys(jobKey)
329
322
  end
@@ -443,6 +436,26 @@ moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedRea
443
436
  end
444
437
  end
445
438
  end
439
+ --[[
440
+ Function to remove deduplication key if needed
441
+ when a job is moved to completed or failed states.
442
+ ]]
443
+ local function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,
444
+ deduplicationId, jobId)
445
+ if deduplicationId then
446
+ local deduplicationKey = prefixKey .. "de:" .. deduplicationId
447
+ local pttl = rcall("PTTL", deduplicationKey)
448
+ if pttl == 0 then
449
+ return rcall("DEL", deduplicationKey)
450
+ end
451
+ if pttl == -1 then
452
+ local currentJobId = rcall('GET', deduplicationKey)
453
+ if currentJobId and currentJobId == jobId then
454
+ return rcall("DEL", deduplicationKey)
455
+ end
456
+ end
457
+ end
458
+ end
446
459
  --[[
447
460
  Function to trim events, default 10000.
448
461
  ]]
@@ -512,7 +525,7 @@ if (#stalling > 0) then
512
525
  local rawParentData = jobAttributes[2]
513
526
  local opts = cjson.decode(rawOpts)
514
527
  rcall("ZADD", failedKey, timestamp, jobId)
515
- removeDeduplicationKeyIfNeeded(queueKeyPrefix, jobAttributes[3])
528
+ removeDeduplicationKeyIfNeededOnFinalization(queueKeyPrefix, jobAttributes[3], jobId)
516
529
  local failedReason = "job stalled more than allowable limit"
517
530
  rcall("HMSET", jobKey, "failedReason", failedReason, "finishedOn", timestamp)
518
531
  rcall("XADD", eventStreamKey, "*", "event", "failed", "jobId", jobId, 'prev', 'active',
@@ -1 +1 @@
1
- {"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6iBf,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -290,18 +290,6 @@ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDep
290
290
  moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
291
291
  end
292
292
  end
293
- --[[
294
- Function to remove deduplication key if needed.
295
- ]]
296
- local function removeDeduplicationKeyIfNeeded(prefixKey, deduplicationId)
297
- if deduplicationId then
298
- local deduplicationKey = prefixKey .. "de:" .. deduplicationId
299
- local pttl = rcall("PTTL", deduplicationKey)
300
- if pttl == 0 or pttl == -1 then
301
- rcall("DEL", deduplicationKey)
302
- end
303
- end
304
- end
305
293
  --[[
306
294
  Functions to remove jobs when removeOnFail option is provided.
307
295
  ]]
@@ -311,13 +299,18 @@ end
311
299
  ]]
312
300
  -- Includes
313
301
  --[[
314
- Function to remove deduplication key.
302
+ Function to remove deduplication key if needed
303
+ when a job is being removed.
315
304
  ]]
316
- local function removeDeduplicationKey(prefixKey, jobKey)
305
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
306
+ jobKey, jobId)
317
307
  local deduplicationId = rcall("HGET", jobKey, "deid")
318
308
  if deduplicationId then
319
309
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
320
- rcall("DEL", deduplicationKey)
310
+ local currentJobId = rcall('GET', deduplicationKey)
311
+ if currentJobId and currentJobId == jobId then
312
+ return rcall("DEL", deduplicationKey)
313
+ end
321
314
  end
322
315
  end
323
316
  --[[
@@ -419,7 +412,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
419
412
  local jobKey = baseKey .. jobId
420
413
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
421
414
  if shouldRemoveDeduplicationKey then
422
- removeDeduplicationKey(baseKey, jobKey)
415
+ removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
423
416
  end
424
417
  removeJobKeys(jobKey)
425
418
  end
@@ -608,6 +601,26 @@ local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedK
608
601
  addBaseMarkerIfNeeded(markerKey, isPaused)
609
602
  end
610
603
  end
604
+ --[[
605
+ Function to remove deduplication key if needed
606
+ when a job is moved to completed or failed states.
607
+ ]]
608
+ local function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,
609
+ deduplicationId, jobId)
610
+ if deduplicationId then
611
+ local deduplicationKey = prefixKey .. "de:" .. deduplicationId
612
+ local pttl = rcall("PTTL", deduplicationKey)
613
+ if pttl == 0 then
614
+ return rcall("DEL", deduplicationKey)
615
+ end
616
+ if pttl == -1 then
617
+ local currentJobId = rcall('GET', deduplicationKey)
618
+ if currentJobId and currentJobId == jobId then
619
+ return rcall("DEL", deduplicationKey)
620
+ end
621
+ end
622
+ end
623
+ end
611
624
  local function removeLock(jobKey, stalledKey, token, jobId)
612
625
  if token ~= "0" then
613
626
  local lockKey = jobKey .. ':lock'
@@ -712,7 +725,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
712
725
  -- Trim events before emiting them to avoid trimming events emitted in this script
713
726
  trimEvents(metaKey, eventStreamKey)
714
727
  local prefix = ARGV[7]
715
- removeDeduplicationKeyIfNeeded(prefix, jobAttributes[3])
728
+ removeDeduplicationKeyIfNeededOnFinalization(prefix, jobAttributes[3], jobId)
716
729
  -- If job has a parent we need to
717
730
  -- 1) remove this job id from parents dependencies
718
731
  -- 2) move the job Id to parent "processed" set
@@ -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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;;;;;;;;;;;;;;;;;;;;;CAi1Bf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -191,18 +191,6 @@ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDep
191
191
  moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
192
192
  end
193
193
  end
194
- --[[
195
- Function to remove deduplication key if needed.
196
- ]]
197
- local function removeDeduplicationKeyIfNeeded(prefixKey, deduplicationId)
198
- if deduplicationId then
199
- local deduplicationKey = prefixKey .. "de:" .. deduplicationId
200
- local pttl = rcall("PTTL", deduplicationKey)
201
- if pttl == 0 or pttl == -1 then
202
- rcall("DEL", deduplicationKey)
203
- end
204
- end
205
- end
206
194
  --[[
207
195
  Functions to remove jobs when removeOnFail option is provided.
208
196
  ]]
@@ -212,13 +200,18 @@ end
212
200
  ]]
213
201
  -- Includes
214
202
  --[[
215
- Function to remove deduplication key.
203
+ Function to remove deduplication key if needed
204
+ when a job is being removed.
216
205
  ]]
217
- local function removeDeduplicationKey(prefixKey, jobKey)
206
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
207
+ jobKey, jobId)
218
208
  local deduplicationId = rcall("HGET", jobKey, "deid")
219
209
  if deduplicationId then
220
210
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
221
- rcall("DEL", deduplicationKey)
211
+ local currentJobId = rcall('GET', deduplicationKey)
212
+ if currentJobId and currentJobId == jobId then
213
+ return rcall("DEL", deduplicationKey)
214
+ end
222
215
  end
223
216
  end
224
217
  --[[
@@ -320,7 +313,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
320
313
  local jobKey = baseKey .. jobId
321
314
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
322
315
  if shouldRemoveDeduplicationKey then
323
- removeDeduplicationKey(baseKey, jobKey)
316
+ removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
324
317
  end
325
318
  removeJobKeys(jobKey)
326
319
  end
@@ -440,6 +433,26 @@ moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedRea
440
433
  end
441
434
  end
442
435
  end
436
+ --[[
437
+ Function to remove deduplication key if needed
438
+ when a job is moved to completed or failed states.
439
+ ]]
440
+ local function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,
441
+ deduplicationId, jobId)
442
+ if deduplicationId then
443
+ local deduplicationKey = prefixKey .. "de:" .. deduplicationId
444
+ local pttl = rcall("PTTL", deduplicationKey)
445
+ if pttl == 0 then
446
+ return rcall("DEL", deduplicationKey)
447
+ end
448
+ if pttl == -1 then
449
+ local currentJobId = rcall('GET', deduplicationKey)
450
+ if currentJobId and currentJobId == jobId then
451
+ return rcall("DEL", deduplicationKey)
452
+ end
453
+ end
454
+ end
455
+ end
443
456
  local function removeLock(jobKey, stalledKey, token, jobId)
444
457
  if token ~= "0" then
445
458
  local lockKey = jobKey .. ':lock'
@@ -473,7 +486,7 @@ if rcall("EXISTS", jobKey) == 1 then
473
486
  if rcall("ZCARD", jobUnsuccessfulKey) ~= 0 then
474
487
  -- TODO: refactor this logic in an include later
475
488
  local jobAttributes = rcall("HMGET", jobKey, "parent", "deid", "opts")
476
- removeDeduplicationKeyIfNeeded(ARGV[5], jobAttributes[2])
489
+ removeDeduplicationKeyIfNeededOnFinalization(ARGV[5], jobAttributes[2], jobId)
477
490
  local failedReason = "children are failed"
478
491
  rcall("ZADD", failedKey, timestamp, jobId)
479
492
  rcall("HSET", jobKey, "finishedOn", timestamp)
@@ -1 +1 @@
1
- {"version":3,"file":"moveToWaitingChildren-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToWaitingChildren-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2gBf,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -25,13 +25,18 @@ local rcall = redis.call
25
25
  ]]
26
26
  -- Includes
27
27
  --[[
28
- Function to remove deduplication key.
28
+ Function to remove deduplication key if needed
29
+ when a job is being removed.
29
30
  ]]
30
- local function removeDeduplicationKey(prefixKey, jobKey)
31
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
32
+ jobKey, jobId)
31
33
  local deduplicationId = rcall("HGET", jobKey, "deid")
32
34
  if deduplicationId then
33
35
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
34
- rcall("DEL", deduplicationKey)
36
+ local currentJobId = rcall('GET', deduplicationKey)
37
+ if currentJobId and currentJobId == jobId then
38
+ return rcall("DEL", deduplicationKey)
39
+ end
35
40
  end
36
41
  end
37
42
  --[[
@@ -169,7 +174,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
169
174
  local jobKey = baseKey .. jobId
170
175
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
171
176
  if shouldRemoveDeduplicationKey then
172
- removeDeduplicationKey(baseKey, jobKey)
177
+ removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
173
178
  end
174
179
  removeJobKeys(jobKey)
175
180
  end
@@ -1 +1 @@
1
- {"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqUf,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Uf,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -88,13 +88,18 @@ local function getOrSetMaxEvents(metaKey)
88
88
  return maxEvents
89
89
  end
90
90
  --[[
91
- Function to remove deduplication key.
91
+ Function to remove deduplication key if needed
92
+ when a job is being removed.
92
93
  ]]
93
- local function removeDeduplicationKey(prefixKey, jobKey)
94
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
95
+ jobKey, jobId)
94
96
  local deduplicationId = rcall("HGET", jobKey, "deid")
95
97
  if deduplicationId then
96
98
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
97
- rcall("DEL", deduplicationKey)
99
+ local currentJobId = rcall('GET', deduplicationKey)
100
+ if currentJobId and currentJobId == jobId then
101
+ return rcall("DEL", deduplicationKey)
102
+ end
98
103
  end
99
104
  end
100
105
  --[[
@@ -306,7 +311,7 @@ removeJobWithChildren = function(prefix, meta, jobId, parentKey, options)
306
311
  removeJobChildren(prefix, meta, jobKey, options)
307
312
  end
308
313
  local prev = removeJobFromAnyState(prefix, jobId)
309
- removeDeduplicationKey(prefix, jobKey)
314
+ removeDeduplicationKeyIfNeededOnRemoval(prefix, jobKey, jobId)
310
315
  if removeJobKeys(jobKey) > 0 then
311
316
  local maxEvents = getOrSetMaxEvents(meta)
312
317
  rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
@@ -1 +1 @@
1
- {"version":3,"file":"removeJob-3.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-3.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Uf,CAAC;AACF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"removeJob-3.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-3.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoVf,CAAC;AACF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -55,13 +55,18 @@ local function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)
55
55
  return false
56
56
  end
57
57
  --[[
58
- Function to remove deduplication key.
58
+ Function to remove deduplication key if needed
59
+ when a job is being removed.
59
60
  ]]
60
- local function removeDeduplicationKey(prefixKey, jobKey)
61
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
62
+ jobKey, jobId)
61
63
  local deduplicationId = rcall("HGET", jobKey, "deid")
62
64
  if deduplicationId then
63
65
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
64
- rcall("DEL", deduplicationKey)
66
+ local currentJobId = rcall('GET', deduplicationKey)
67
+ if currentJobId and currentJobId == jobId then
68
+ return rcall("DEL", deduplicationKey)
69
+ end
65
70
  end
66
71
  end
67
72
  --[[
@@ -303,7 +308,7 @@ removeJobWithChildren = function(prefix, meta, jobId, parentKey, options)
303
308
  removeJobChildren(prefix, meta, jobKey, options)
304
309
  end
305
310
  local prev = removeJobFromAnyState(prefix, jobId)
306
- removeDeduplicationKey(prefix, jobKey)
311
+ removeDeduplicationKeyIfNeededOnRemoval(prefix, jobKey, jobId)
307
312
  if removeJobKeys(jobKey) > 0 then
308
313
  local maxEvents = getOrSetMaxEvents(meta)
309
314
  rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
@@ -1 +1 @@
1
- {"version":3,"file":"removeUnprocessedChildren-2.js","sourceRoot":"","sources":["../../../src/scripts/removeUnprocessedChildren-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmUf,CAAC;AACF,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,2BAA2B;IACjC,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"removeUnprocessedChildren-2.js","sourceRoot":"","sources":["../../../src/scripts/removeUnprocessedChildren-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwUf,CAAC;AACF,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,2BAA2B;IACjC,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -152,7 +152,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
152
152
  table.insert(optionalValues, "parent")
153
153
  table.insert(optionalValues, parentData)
154
154
  end
155
- if repeatJobKey ~= nil then
155
+ if repeatJobKey then
156
156
  table.insert(optionalValues, "rjk")
157
157
  table.insert(optionalValues, repeatJobKey)
158
158
  end
@@ -232,7 +232,7 @@ local nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis
232
232
  local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
233
233
  -- Validate that scheduler exists.
234
234
  local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
235
- if prevMillis ~= false then
235
+ if prevMillis then
236
236
  local currentDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
237
237
  if producerId == currentDelayedJobId then
238
238
  local eventsKey = KEYS[9]