redis / lettuce

Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
https://lettuce.io
MIT License
5.3k stars 949 forks source link

Add option to customize expected exceptions in `DefaultEndpoint` #2830

Open eager-signal opened 2 months ago

eager-signal commented 2 months ago

Feature Request

Is your feature request related to a problem? Please describe

We’ve implemented a circuit breaker using a Netty Customizer as suggested in #1530 discussion. We now observe a large volume of logs from DefaultEndpoint when the circuit breaker is open, because the command is completed exceptionally with an exception class that is not expected by this code block.

Describe the solution you'd like

We’d like to specify in ClientOptions a set of exception classes that should not be logged, similar to how ClosedChannelException is skipped. A drawback of this is additional complexity for a relatively advanced use case.

Describe alternatives you've considered

We considered wrapping our internal exception in ClosedChannelException. I believe this would work fine with the current Lettuce implementation, but it seems incorrect to do this, because a Channel that closes cannot re-open, and the circuit breaker will very likely permit future calls on the same channel.

Teachability, Documentation, Adoption, Migration Strategy

This would be opt-in—the default client option would be an empty set.

mp911de commented 2 months ago

Thanks a lot for following up. Let's take a step back before digging into code changes. Looking at the broader context, I wonder whether RetryListener usage is even appropriate. When using a CircuitBreaker, I understand that you want to fail fast and not necessarily retry commands.

If so, then it would even make sense to figure out a way to control when to apply at most once/retry listeners onto commands.