Description
Feature Request
Is your feature request related to a problem? Please describe
Sometimes need to shut down Redis for maintenance, such as version upgrades. When shutdown or kill redis-server, connection is disconnected immediatly. But some requests do not fail immediately but instead experience timeouts, increasing application latency.
Currently, our Redis client options are configured as follows:
ClientOptions options = ClientOptions.builder()
.autoReconnect(true)
.disconnectedBehavior(DisconnectedBehavior.REJECT_COMMANDS)
// ...
The DisconnectedBehavior.REJECT_COMMANDS option appears to cancel commands when the connection is lost. However, if autoReconnect is not set to false, commands in the CommandHandler.stack are not canceled but are placed into the disconnectedBuffer. Therefore, ongoing commands are not rejected if autoReconnect is true, even with the client option modified.
Describe the solution you'd like
Condition for canceling commands in the CommandHandler.stack should be based solely on rejectCommandsWhileDisconnected and not combined with autoReconnect.
Describe alternatives you've considered
- make other client options
adding a little more complexity, which can be beneficial for migrations such as versioning because they don't change existing behavior
- just disable reconnect option.
Adjusting the autoReconnect option can solve this issue immediately, but it would require implement custom reconnect connection.
I want to avoid writing custom code for reconnections by using the auto-reconnect feature.
Teachability, Documentation, Adoption, Migration Strategy
Maybe we need to update docs for disconnectedBehavior option.