hiredis icon indicating copy to clipboard operation
hiredis copied to clipboard

Resource Temporarily Unavailable In redisAsyncCommand

Open ayeganov opened this issue 3 years ago • 6 comments

Hello, I've implemented a C++ async wrapper around the async hiredis API using the following example as a starting point:

https://github.com/ryangraham/hiredis-boostasio-adapter

Everything works fine the vast majority of the time, but there are occasional errors that trigger a disconnect with the context error context->errstr saying Resource Temporarily Unavailable. Before the disconnect the last callback fails with the null reply.

The redis instance does not show any signs of crashing... I've tracked down the error to ssl.c:457, so it appears to be related to not having the data be available yet. I could implement a retry on my end and handle it that way - except why does the disconnect callback get triggered?

ayeganov avatar Feb 03 '21 22:02 ayeganov

It appears that the disconnect is the expected behavior. My understanding at this point is that it is upon me to retry all calls that were reported as have failed.

ayeganov avatar Feb 05 '21 15:02 ayeganov

Is it possible to communicate back a special error code from hiredis indicating the issue is EAGAIN or EWOULDBLOCK, because those are not critical problems necessitating a disconnect. Maybe I am wrong on this, but I expected hiredis to retry "under the hood" - instead of failing every pending callback.

ayeganov avatar Feb 05 '21 15:02 ayeganov

Hi @ayeganov, I didn't write the SSL layer but it does feel like a Resource Temporarily Unavailable error should be handled like EAGAIN for an async context.

I'll dig into the logic and see if that's something we can do. Do you have any tips for triggering that condition on purpose?

michael-grunder avatar Feb 05 '21 21:02 michael-grunder

@michael-grunder I am trying to figure out how to trigger EAGAIN myself. Some options I see:

  1. Simulate the connection socket, but you would have to basically implement some portions of the redis protocol before issuing the error causing the EAGAIN
  2. Mock up the call to redisGetReply with this library https://github.com/meekrosoft/fff

But have not thought fully through each option yet. I feel like I am missing a much simpler solution to this problem.

ayeganov avatar Feb 06 '21 23:02 ayeganov

@ayeganov Are you still having problems with this?

michael-grunder avatar Sep 07 '22 02:09 michael-grunder

I'm not sure this is exactly relevant. But I'm having the same error using the redis-client ruby library when trying to connect over tls via an AWS NLB to an elastic cache redis 7. Using the pure ruby driver works just fine

elthariel avatar Jun 15 '23 22:06 elthariel