ci-queue 0.100.0 → 0.101.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ci/queue/redis/requeue.lua +22 -7
- data/lib/ci/queue/redis/reserve.lua +18 -7
- data/lib/ci/queue/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 612d0f2f3077fdd5b7e74b343649a162101c2961c8b4cda8329ca10fbd831e6b
|
|
4
|
+
data.tar.gz: bdd01c95971bcbfab5999b3754f8d019be35a7202e5f766d5df19191462e5563
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69a03983e12372fe0ab0258ec08262b2672624d49d2d63a0c35d0a89b4c8c85b3fd89ece2ce3c71de112652cd327868ee0fa7633ae283facb3b0bf57035d5724
|
|
7
|
+
data.tar.gz: 44ead0bb47b690b19652982496f8a48d698f5bb78ea4f88c01e56b7774d4c79f6b6015b50e91cb70e241fc00a13bf842a72828792c7f716644cacf12bfb8bb2d
|
data/Gemfile.lock
CHANGED
|
@@ -12,10 +12,30 @@ local leases_key = KEYS[9]
|
|
|
12
12
|
local max_requeues = tonumber(ARGV[1])
|
|
13
13
|
local global_max_requeues = tonumber(ARGV[2])
|
|
14
14
|
local entry = ARGV[3]
|
|
15
|
-
local offset = ARGV[4]
|
|
15
|
+
local offset = tonumber(ARGV[4]) or 0
|
|
16
16
|
local ttl = tonumber(ARGV[5])
|
|
17
17
|
local lease_id = ARGV[6]
|
|
18
18
|
|
|
19
|
+
-- Inserts `entry` behind the `offset` + 1 entries nearest the tail, the end RPOP reserves
|
|
20
|
+
-- from: where `LINSERT BEFORE <entry at index -(offset + 1)>` would put it. LINSERT finds its
|
|
21
|
+
-- pivot by scanning from the head, which is O(queue length) and blocks Redis on large queues;
|
|
22
|
+
-- this only touches the tail, so it is O(offset). Queues of at most `offset` + 1 entries, and
|
|
23
|
+
-- offsets of zero or less, push to the head instead.
|
|
24
|
+
-- Keep in sync with reserve.lua: the Python client does not resolve `-- @include`.
|
|
25
|
+
local function insert_with_offset(queue_key, entry, offset)
|
|
26
|
+
if offset <= 0 or redis.call('llen', queue_key) <= offset + 1 then
|
|
27
|
+
redis.call('lpush', queue_key, entry)
|
|
28
|
+
return
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
local ahead = redis.call('lrange', queue_key, -1 - offset, -1)
|
|
32
|
+
redis.call('ltrim', queue_key, 0, -2 - offset)
|
|
33
|
+
redis.call('rpush', queue_key, entry)
|
|
34
|
+
for _, ahead_entry in ipairs(ahead) do
|
|
35
|
+
redis.call('rpush', queue_key, ahead_entry)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
19
39
|
-- Only the current lease holder can requeue a test.
|
|
20
40
|
-- If the lease was transferred (e.g. via reserve_lost), reject the stale
|
|
21
41
|
-- worker's requeue so the running entry stays intact for the new holder.
|
|
@@ -42,12 +62,7 @@ redis.call('hincrby', requeues_count_key, entry, 1)
|
|
|
42
62
|
|
|
43
63
|
redis.call('hdel', error_reports_key, entry)
|
|
44
64
|
|
|
45
|
-
|
|
46
|
-
if pivot then
|
|
47
|
-
redis.call('linsert', queue_key, 'BEFORE', pivot, entry)
|
|
48
|
-
else
|
|
49
|
-
redis.call('lpush', queue_key, entry)
|
|
50
|
-
end
|
|
65
|
+
insert_with_offset(queue_key, entry, offset)
|
|
51
66
|
|
|
52
67
|
redis.call('hset', requeued_by_key, entry, worker_queue_key)
|
|
53
68
|
if ttl and ttl > 0 then
|
|
@@ -13,12 +13,23 @@ local current_time = ARGV[1]
|
|
|
13
13
|
local defer_offset = tonumber(ARGV[2]) or 0
|
|
14
14
|
local max_skip_attempts = 4
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
-- Inserts `entry` behind the `offset` + 1 entries nearest the tail, the end RPOP reserves
|
|
17
|
+
-- from: where `LINSERT BEFORE <entry at index -(offset + 1)>` would put it. LINSERT finds its
|
|
18
|
+
-- pivot by scanning from the head, which is O(queue length) and blocks Redis on large queues;
|
|
19
|
+
-- this only touches the tail, so it is O(offset). Queues of at most `offset` + 1 entries, and
|
|
20
|
+
-- offsets of zero or less, push to the head instead.
|
|
21
|
+
-- Keep in sync with requeue.lua: the Python client does not resolve `-- @include`.
|
|
22
|
+
local function insert_with_offset(queue_key, entry, offset)
|
|
23
|
+
if offset <= 0 or redis.call('llen', queue_key) <= offset + 1 then
|
|
24
|
+
redis.call('lpush', queue_key, entry)
|
|
25
|
+
return
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
local ahead = redis.call('lrange', queue_key, -1 - offset, -1)
|
|
29
|
+
redis.call('ltrim', queue_key, 0, -2 - offset)
|
|
30
|
+
redis.call('rpush', queue_key, entry)
|
|
31
|
+
for _, ahead_entry in ipairs(ahead) do
|
|
32
|
+
redis.call('rpush', queue_key, ahead_entry)
|
|
22
33
|
end
|
|
23
34
|
end
|
|
24
35
|
|
|
@@ -45,7 +56,7 @@ for attempt = 1, max_skip_attempts do
|
|
|
45
56
|
return claim_test(test)
|
|
46
57
|
end
|
|
47
58
|
|
|
48
|
-
insert_with_offset(test)
|
|
59
|
+
insert_with_offset(queue_key, test, defer_offset)
|
|
49
60
|
|
|
50
61
|
-- If this worker only finds its own requeued tests, defer once by returning nil,
|
|
51
62
|
-- then allow pickup on a subsequent reserve attempt.
|
data/lib/ci/queue/version.rb
CHANGED