Skip to content

Adjusting disconnectedBehavior Option to Prevent Timeout When Redis Shutdown #2866

@MagicalLas

Description

@MagicalLas

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.

(sample implementation)

Describe alternatives you've considered

  1. 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

  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions