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 16, 2024
1 parent defca71 commit b7c10b8
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._client.timeout
redis._client.timeout = timeout
yield
ensure
redis._client.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 ::Redis::BaseError => error
if !queue_initialized? && attempts < 3
Expand Down

0 comments on commit b7c10b8

Please sign in to comment.