Skip to content

Commit

Permalink
Bump Redis timeout for pushing to the queue
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBr committed Sep 12, 2024
1 parent 168bd8b commit 3f1c3f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
8 changes: 8 additions & 0 deletions ruby/lib/ci/queue/redis/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ def max_test_failed?

attr_reader :redis, :redis_url

def with_redis_timeout(timeout)
prev = redis.timeout
redis.timeout = timeout
yield
ensure
redis.timeout = prev
end

def measure
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
yield
Expand Down
20 changes: 11 additions & 9 deletions ruby/lib/ci/queue/redis/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,17 @@ def push(tests)

attempts = 0
duration = measure do
redis.without_reconnect do
redis.multi do |transaction|
transaction.lpush(key('queue'), tests) unless tests.empty?
transaction.set(key('total'), @total)
transaction.set(key('master-status'), 'ready')

transaction.expire(key('queue'), config.redis_ttl)
transaction.expire(key('total'), config.redis_ttl)
transaction.expire(key('master-status'), config.redis_ttl)
with_redis_timeout(5) do
redis.without_reconnect do
redis.multi do |transaction|
transaction.lpush(key('queue'), tests) unless tests.empty?
transaction.set(key('total'), @total)
transaction.set(key('master-status'), 'ready')

transaction.expire(key('queue'), config.redis_ttl)
transaction.expire(key('total'), config.redis_ttl)
transaction.expire(key('master-status'), config.redis_ttl)
end
end
rescue StandardError => error
if !queue_initialized? && attempts < 3
Expand Down

0 comments on commit 3f1c3f8

Please sign in to comment.