redis / hiredis-rb

Ruby wrapper for hiredis
BSD 3-Clause "New" or "Revised" License
320 stars 90 forks source link

Rescue EINVAL errors when connecting #29

Closed adamstep closed 10 years ago

adamstep commented 10 years ago
pietern commented 10 years ago

Do you know what's causing the EINVAL?

Looks like this change addresses a symptom, instead of a cause.

adamstep commented 10 years ago

It seemed to be the same issue discussed here: https://github.com/redis/hiredis-rb/issues/21, so I tried out the suggestion you mentioned at the bottom of the thread.

pietern commented 10 years ago

Did increasing the allowed number of file descriptors solve the issue for you?

scalp42 commented 10 years ago

Hitting the same issue here, bumped to 10k no problems.

scalp42 commented 10 years ago

Actually I just hit it again:

/Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/connection/hiredis.rb:16:in `connect': Invalid argument (Errno::EINVAL)
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/connection/hiredis.rb:16:in `connect'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/client.rb:304:in `establish_connection'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/client.rb:85:in `block in connect'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/client.rb:266:in `with_reconnect'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/client.rb:84:in `connect'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/client.rb:326:in `ensure_connected'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/client.rb:197:in `block in process'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/client.rb:279:in `logging'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/client.rb:196:in `process'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis/client.rb:102:in `call'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis.rb:84:in `block in ping'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis.rb:37:in `block in synchronize'
    from /Users/scalp/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis.rb:37:in `synchronize'
    from /Users/scalp/.rvm/gems/ruby-2.1.2@gourmet/gems/redis-3.1.0/lib/redis.rb:83:in `ping'
    from /Users/scalp/audax/gourmet/plugins/redis.rb:12:in `redis'
    from /Users/scalp/audax/gourmet/plugins/sensu_server.rb:3:in `sensu_server'
    from ./gourmet.rb:27:in `block (2 levels) in <main>'
    from /Users/scalp/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout'
    from /Users/scalp/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:35:in `block in catch'
    from /Users/scalp/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:35:in `catch'
    from /Users/scalp/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:35:in `catch'
    from /Users/scalp/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:106:in `timeout'
    from ./gourmet.rb:22:in `block in <main>'
    from ./gourmet.rb:19:in `each'
    from ./gourmet.rb:19:in `<main>'

Doesn't like the redis.ping command:

  begin
    @redis ||= Redis.new(host: host, port: port, db: database, timeout: 2.0, driver: :hiredis)
    @redis.ping
  rescue Redis::CannotConnectError
    logger.warn %Q(#{__method__.to_s} => Could not connect to Redis (#{host}:#{port}:#{database}))
    return 1
  end
scalp42 commented 10 years ago

Let me know what you need to help debugging.