bullmq 1.37.0 → 1.37.1
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.
@@ -23,6 +23,19 @@
|
|
23
23
|
]]
|
24
24
|
local rcall = redis.call
|
25
25
|
|
26
|
+
local function batches(n, batchSize)
|
27
|
+
local i = 0
|
28
|
+
|
29
|
+
return function()
|
30
|
+
local from = i * batchSize + 1
|
31
|
+
i = i + 1
|
32
|
+
if (from <= n) then
|
33
|
+
local to = math.min(from + batchSize - 1, n)
|
34
|
+
return from, to
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
26
39
|
-- Check if we need to check for stalled jobs now.
|
27
40
|
if rcall("EXISTS", KEYS[5]) == 1 then return {{}, {}} end
|
28
41
|
|
@@ -86,7 +99,12 @@ end
|
|
86
99
|
|
87
100
|
-- Mark potentially stalled jobs
|
88
101
|
local active = rcall('LRANGE', KEYS[3], 0, -1)
|
89
|
-
|
102
|
+
|
103
|
+
if (#active > 0) then
|
104
|
+
for from, to in batches(#active, 7000) do
|
105
|
+
rcall('SADD', KEYS[1], unpack(active, from, to))
|
106
|
+
end
|
107
|
+
end
|
90
108
|
|
91
109
|
local maxEvents = rcall("HGET", KEYS[6], "opts.maxLenEvents")
|
92
110
|
if maxEvents then rcall("XTRIM", KEYS[8], "MAXLEN", "~", maxEvents) end
|