I am working on a Rails project deployed on Heroku with two add-ons (Heroku Scheduler and Heroku Redis for Data) that are supposed to launch jobs at a certain time.
I don't know exactly when this issue started occurring, but we have noticed bugs raised in our bug management app. The reported bugs are:
RedisClient::CannotConnectError name_of_the_rake_task getaddrinfo: Name or service not known
We have managed to understand that this error message appears to be similar to an unknown hostname error or something indicating a lack of information for connecting Redis to the Scheduler.
These errors occur every time the job should be launched; sometimes the job is launched correctly, and sometimes it is not. Even after deleting jobs from Heroku Scheduler, the errors persist.
The problem doesn't seem to be coming from the performance or the plan used with heroku redis add-on, we have access to 100mb/month, we use at max 2mb.
I use:
ruby '3.1.0'gem 'rails', '7.0.4'gem 'redis', '5.0.6'redis-client (>= 0.9.0)
Version of Heroku Redis for Data: 6.2.14Plan: premium-1
We try to rebuild configuration in our rails app by rewrite, as the heroku doc suggest the files:
- initializers/redis.rb
$redis = Redis.new(url: ENV["REDIS_URL"], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE })
- initializers/sikekiq.rb
# $redis = Redis.newSidekiq.configure_server do |config| config.redis = { url: ENV["REDIS_URL"], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } }endSidekiq.configure_client do |config| config.redis = { url: ENV["REDIS_URL"], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } }end
We deleted the environment variable configuration for 'REDIS_URL' in our Heroku admin panel, allowing Heroku to manage this element automatically.
Also, as mention in this doc we set REDIS_PROVIDER to REDIS_URL in heroku.