redis-rb
redis-rb copied to clipboard
IOError: closed stream (JRuby 9.2.7)
We've been having some issues with a threaded app that is using a connection pool too manage multiple Redis connections with this gem. On start-up, we intermittently get IOError exceptions. I've been digging through the code base, but have had no luck pinpointing the issue.
I did try both the latest release (4.0.3) and head (9101933).
Not sure if it's a bug or an issue with how the gem is being used, but I'm hoping for some assistance.
IOError: closed stream
write_nonblock at org/jruby/RubyIO.java:1365
_write_to_socket at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/connection/ruby.rb:87
write at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/connection/ruby.rb:113
loop at org/jruby/RubyKernel.java:1425
write at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/connection/ruby.rb:112
write at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/connection/ruby.rb:380
write at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/client.rb:281
io at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/client.rb:260
write at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/client.rb:279
process at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/client.rb:238
each at org/jruby/RubyArray.java:1792
process at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/client.rb:232
ensure_connected at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/client.rb:384
process at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/client.rb:231
logging at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/client.rb:339
process at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/client.rb:230
call at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis/client.rb:125
get at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis.rb:914
synchronize at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis.rb:52
mon_synchronize at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/monitor.rb:226
synchronize at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis.rb:52
get at /jruby-app/vendor/bundler/jruby/2.5.0/bundler/gems/redis-rb-9101933c84d1/lib/redis.rb:913
get at /lib/redis/redis_store.rb:71
with at /jruby-app/vendor/bundler/jruby/2.5.0/gems/connection_pool-2.2.2/lib/connection_pool.rb:65
handle_interrupt at org/jruby/RubyThread.java:759
with at /jruby-app/vendor/bundler/jruby/2.5.0/gems/connection_pool-2.2.2/lib/connection_pool.rb:64
handle_interrupt at org/jruby/RubyThread.java:759
with at /jruby-app/vendor/bundler/jruby/2.5.0/gems/connection_pool-2.2.2/lib/connection_pool.rb:61
If it's relevant, I'm creating the pool like so:
pool = ConnectionPool.new(size: pool_size, timeout: pool_timeout) do
Redis.new(redis_config)
end
Did you try against different servers? I'm asking this because the exception suggest the connection was closed by the server. It could be a configuration issue with your server, or some network issue.
That being said the library should handle such error better.
I did try against different servers. I've seen it on Ubuntu and was able to reproduce with the same code base on MacOS.
Closing as non actionable.
I assume the server is closing the connection for some reason (maybe max-clients?). I don't see anything we can do about it.