hiredis icon indicating copy to clipboard operation
hiredis copied to clipboard

Is the reidsAsyncDiscconnect called by user will be better when the timeout happend?

Open corznoc opened this issue 4 years ago • 1 comments

I see the __redisAsyncDisconnect called by the redisHandleTimeout function:

void redisAsyncHandleTimeout(redisAsyncContext *ac) {
    redisContext *c = &(ac->c);
    redisCallback cb;
    ...
    /**
     * TODO: Don't automatically sever the connection,
     * rather, allow to ignore <x> responses before the queue is clear
     */
    __redisAsyncDisconnect(ac);
}

but sometimes the connection is ok, so, could you let it called by the caller? Another question: consider the following case, when the timeout event comming, if we not disconnect the connection, and we have called redisAsyncCommand after this, can we distinguish which command the upcoming callback belongs to?

corznoc avatar Apr 08 '20 10:04 corznoc

but sometimes the connection is ok, so, could you let it called by the caller?

Presently we simply disconnect from the server when encountering a timeout, but the comment describes a theoretical way to handle timeouts in a non-fatal way.

It would be non-trivial but we could probably achieve that by doing the following:

  1. Tag every command with a timestamp.
  2. As we process replies we would detect every command that has actually timed out, invoke a callback, and increment an error counter.
  3. Once we encounter a command that has not timed out we return that and continue with normal operation.

I don't presently have plans to implement such a feature but I'll keep it open and add it as a wishlist. If there is sufficient interest it may be worth doing.

michael-grunder avatar Apr 08 '20 20:04 michael-grunder