-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Periodic redis errors #428
Comments
Thank you for you report! I'll investigate the issue. |
Something else I've noticed is that the existing nginx workers take an unusually long amount of time to shut down when I run a |
@matsumotory Any ideas on this? |
Sorry for my late response. I think Redis client timed out. So Could you implement reconnecting Redis when catching timeout error like Redis::ConnectionError? |
Yes, I can try. I can try wrapping the |
Yes, it's strange behavior. Maybe OS or middleware layer settings disconnects the TCP connection I guess. |
@matsumotory Is there a reconnect interface or method on the mruby-redis client? |
@ajsharp @matsumotory |
@matsumotory We're using the same redis server (AWS elasticache) in our main app from the same host machine without connection issues, so the problem is almost definitely in this library in some way. It's unclear whether the problem is the redis client this project uses or some lower level issue with the nginx extension. However, it's not an OS/middleware issue b/c we're maintaining persistent connections to the same redis server from the same host machine without any problems. @afunction The only "fix" we've found is to restart every 8 mins or so. It seems like there's some sort of redis connection issue. When I tried to diagnose this before, I started looking through the redis client this project bundles, but I don't have the expertise or the time to get into the C++ code. It would be great if it was possible to add additional logging instrumentation around the connection logic. |
@ajsharp @afunction I'm wondering if you guys can move Redis.new into mruby_ssl_handshake_handler_code? I don't think redis[], mrb_redis_get() in C, supports reconnect. It looks like _redisContextConnectTcp() in hredis supports it, but it is only called via redisConnectWithTimeout() from the following methods.
Disclaimer: I have never used redis. I just looked at mruby-redis and hired code while waiting for windows update. |
@yyamano Thank you for your suggestion. @ajsharp @afunction Could you try to use |
Or you can implement error handling like this example. |
@matsumotory I tried using |
I've put begin/rescue blocks in both the begin
ssl = Nginx::SSL.new
domain = ssl.servername
redis = Userdata.new.redis
ssl_certificate = redis["#{domain}.crt"]
ssl_key = redis["#{domain}.key"]
if ssl_certificate && ssl_certificate != "" && ssl_key && ssl_key != ""
ssl.certificate_data = ssl_certificate
ssl.certificate_key_data = ssl_key
end
rescue Redis::ReplyError => e
STDERR.puts "HANDSHAKE REPLY ERROR: #{e}"
rescue Redis::ConnectionError => e
STDERR.puts "HANDSHAKE CONN ERROR: #{e}"
end I'm seeing lots of |
@matsumotory Is it possible to add more context here to the error message? |
@ajsharp Thank you for your details. I have implemented your suggestion on matsumotory/mruby-redis#102 . Could you try this? |
@ajsharp Do you still have the problem with the newer version of mruby-redis ? |
@yyamano I will try an upgrade and let you know. Thanks for checking in on this. |
@yyamano Is the latest version of mruby-redis installed with the latest version of this library? |
@ajsharp If you rebuild ngx_mruby, the latest version of mruby-redis including the change is installed.
|
I'm using ngx_mruby to do dynamic lets encrypt ssl resolution. Currently building from source against nginx 1.16.0 and ngx_mruby 2.1.5.
Here's the relevant parts of the configuration:
After roughly 45 minutes of running ngx_mruby, i start to see these redis connection failures:
If I reload nginx, the errors stop. If I let the server run for about 45 minutes, they will inevitably return. Right now I'm avoiding these by reloading nginx every 15 minutes on a cron job, but it seems like there's some sort of issue with the embedded ruby code that causes the redis connection to stop working eventually. Maybe the embedded ruby code is leaving redis connections hanging or something.
The server this running on has unlimited ulimit and the number of open redis connections has never exceeded a couple hundred.
Has anyone else seen these types of errors?
The text was updated successfully, but these errors were encountered: