Stackexchange.redis: Which Redis exceptions to retry on

Created on 3 Feb 2017  ·  3Comments  ·  Source: StackExchange/StackExchange.Redis

As per StackExchange.Redis code, following exceptions seem like they need to be retried (connection error, sever error).

RedisServerException: Indicates an exception raised by a redis server

RedisConnectionException
Indicates a connection fault when communicating with redis

RedisException
Indicates an issue communicating with redis_

Is it safe to retry on these errors? Are they any other exceptions that need to be retried on?

Redis Best practices:
https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#when-is-it-safe-to-retry
puts onus on users of Redis for retries. But is silent which exceptions can be safely retried.

Thanks,

question

Most helpful comment

OK thanks for the link.
Follow up question:
If I decide to retry for errors in Redis operation:

  1. Should I create a new ConnectionMultiplexer and retry
  2. Or using existing ConnectionMultiplexer object for retries

In case of errors I perform following two operations:

  1. GetDatabase again
  2. StringSet\StringGet\ other Redis op that needs to be retried.

All 3 comments

Where you retry depends on what you're trying to do, see my comments here on why it's so specific to the intent and not the exception:
https://github.com/StackExchange/StackExchange.Redis/issues/528#issuecomment-268989780

OK thanks for the link.
Follow up question:
If I decide to retry for errors in Redis operation:

  1. Should I create a new ConnectionMultiplexer and retry
  2. Or using existing ConnectionMultiplexer object for retries

In case of errors I perform following two operations:

  1. GetDatabase again
  2. StringSet\StringGet\ other Redis op that needs to be retried.

It depends on the error, if it's a connection error and you want to synchronously wait then you may create a new one. But doing so for a large number of commands would be very expensive.

Was this page helpful?
0 / 5 - 0 ratings