Skip to content

Commit

Permalink
Ruby/Redis: retry connection errors more agressively
Browse files Browse the repository at this point in the history
Booting a CI worker is costly, so in case of a Redis blip,
it makes sense to retry for a while before giving up.
  • Loading branch information
byroot committed Dec 11, 2023
1 parent 360a805 commit b403d0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions ruby/lib/ci/queue/redis.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

gem 'redis', '>= 5'
require 'redis'
require 'ci/queue/redis/build_record'
require 'ci/queue/redis/base'
Expand Down
7 changes: 6 additions & 1 deletion ruby/lib/ci/queue/redis/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ class Base

def initialize(redis_url, config)
@redis_url = redis_url
@redis = ::Redis.new(url: redis_url)
@redis = ::Redis.new(
url: redis_url,
# Booting a CI worker is costly, so in case of a Redis blip,
# it makes sense to retry for a while before giving up.
reconnect_attempts: [0, 0, 0.1, 0.5, 1, 3, 5],
)
@config = config
end

Expand Down

0 comments on commit b403d0c

Please sign in to comment.