From d3f2458a2460ff95ab5735f242ef70f10111e7c7 Mon Sep 17 00:00:00 2001 From: Tobias Madner Date: Tue, 24 Mar 2020 15:02:48 +0100 Subject: [PATCH] fix unpacking too many values, taken from existing PR-#123 --- lib/lua/raiseDelayedJobs.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/lua/raiseDelayedJobs.lua b/lib/lua/raiseDelayedJobs.lua index 710a7b63..10f50a33 100644 --- a/lib/lua/raiseDelayedJobs.lua +++ b/lib/lua/raiseDelayedJobs.lua @@ -10,13 +10,21 @@ returns number of jobs raised and the timestamp of the next job (within the near local now = tonumber(ARGV[1]) -- raise any delayed jobs that are now valid by moving from delayed to waiting -local raising = redis.call("zrangebyscore", KEYS[1], 0, ARGV[1]) -local numRaising = #raising +local offset = 0 +-- There is a default 1024 element restriction +local count = 1000 +while true do + local raising = redis.call("zrangebyscore", KEYS[1], 0, ARGV[1], 'LIMIT', offset, count) + local numRaising = #raising + offset = offset + numRaising -if numRaising > 0 then - redis.call("lpush", KEYS[2], unpack(raising)) - redis.call("zremrangebyscore", KEYS[1], 0, ARGV[1]) + if numRaising > 0 then + redis.call("lpush", KEYS[2], unpack(raising)) + else + break + end end +redis.call("zremrangebyscore", KEYS[1], 0, ARGV[1]) local head = redis.call("zrange", KEYS[1], 0, 0, "WITHSCORES") local nearTerm = -1 @@ -25,4 +33,4 @@ if next(head) ~= nil then nearTerm = proximal[2] end -return {numRaising, nearTerm} +return {offset, nearTerm} \ No newline at end of file