Description
Hi,
we recently upgraded to Redis 6 and started using the built-in TLS. Since the upgrade we see frequent IO::EINPROGRESSWaitWritable: Operation now in progress - connect(2) would block
versions:
ruby: 2.7.2
redis-rb: 4.2.5
redis: 6.0.8
We use Redis in combination with Sidekiq.
What we found out so far:
- Sidekiq is using the default configuration with the ConnectionPool gem.
- Sidekiq gets a connection from the pool
- redis-rb runs
ensure_connected
(Lines 383 to 392 in 72bd3a3
- the connection from the pool is dead, redis-rb tries to reconnect and fails.
This is happening in bursts every 5min which is also the timeout
setting on our redis.
Setting timeout
on the redis to 0 (disable) "fixes" this problem.
What I think is happening. The connection in the pool was timed out by redis and when we try to use it, it fails to connect again.
This only started to happen after upgrading from Redis 4 to 6. Our old Redis 4 had the same 300s timeout. I believe that I might be related to TLS.
stack trace:
File /app/vendor/ruby-2.7.2/lib/ruby/2.7.0/socket.rb line 1214 in __connect_nonblock
File /app/vendor/ruby-2.7.2/lib/ruby/2.7.0/socket.rb line 1214 in connect_nonblock
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/connection/ruby.rb line 154 in connect_addrinfo
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/connection/ruby.rb line 192 in block in connect
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/connection/ruby.rb line 190 in each
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/connection/ruby.rb line 190 in each_with_index
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/connection/ruby.rb line 190 in connect
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/connection/ruby.rb line 243 in connect
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/connection/ruby.rb line 302 in connect
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 354 in establish_connection
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 112 in block in connect
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 313 in with_reconnect
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 111 in connect
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 386 in ensure_connected
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 238 in block in process
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 325 in logging
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 237 in process
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 131 in call
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 226 in block in call_with_timeout
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 300 in with_socket_timeout
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb line 225 in call_with_timeout
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis.rb line 1224 in block in _bpop
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis.rb line 69 in block in synchronize
File /app/vendor/ruby-2.7.2/lib/ruby/2.7.0/monitor.rb line 202 in synchronize
File /app/vendor/ruby-2.7.2/lib/ruby/2.7.0/monitor.rb line 202 in mon_synchronize
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis.rb line 69 in synchronize
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis.rb line 1221 in _bpop
File /app/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis.rb line 1266 in brpop
File /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.1.2/lib/sidekiq/fetch.rb line 39 in block in retrieve_work
File /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.1.2/lib/sidekiq.rb line 98 in block in redis
File /app/vendor/bundle/ruby/2.7.0/gems/connection_pool-2.2.3/lib/connection_pool.rb line 63 in block (2 levels) in with
File /app/vendor/bundle/ruby/2.7.0/gems/connection_pool-2.2.3/lib/connection_pool.rb line 62 in handle_interrupt
File /app/vendor/bundle/ruby/2.7.0/gems/connection_pool-2.2.3/lib/connection_pool.rb line 62 in block in with
File /app/vendor/bundle/ruby/2.7.0/gems/connection_pool-2.2.3/lib/connection_pool.rb line 59 in handle_interrupt
File /app/vendor/bundle/ruby/2.7.0/gems/connection_pool-2.2.3/lib/connection_pool.rb line 59 in with
File /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.1.2/lib/sidekiq.rb line 95 in redis
File /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.1.2/lib/sidekiq/fetch.rb line 39 in retrieve_work
File /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.1.2/lib/sidekiq/processor.rb line 83 in get_one
File /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.1.2/lib/sidekiq/processor.rb line 95 in fetch
File /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.1.2/lib/sidekiq/processor.rb line 77 in process_one
File /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.1.2/lib/sidekiq/processor.rb line 68 in run
File /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.1.2/lib/sidekiq/util.rb line 15 in watchdog
File /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-6.1.2/lib/sidekiq/util.rb line 24 in block in safe_thread
So far I failed to reproduce this issue in a new isolated project.
let me know if there is more information that I can provide.