I have a policy wrap with WaitAndRetry and CircuitBreaker policies, so, from my understanding the circuit only breaks when the exception is the same consecutively.
So, the GetRandomException method returns a SqlException randomly (40613, 40197, 40501 or 49918). So, my circuit breaker policy is configured to break the circuit after 3 exceptions, but I would expect that only happen if I throw, let's say the 40613 SqlException in a row 3 times, but currently, it's breaking the circuit despite I'm throwing random exceptions.
I don't know if I'm misunderstanding the usage or I have something wrong with the policies.
The text was updated successfully, but these errors were encountered:
reisenberger
changed the title
Issue with CircuitBreaker policy
Circuit-breakers count all faults they handle as an aggregate, not separately
Jul 20, 2018
The circuit-breaker will break after N consecutive actions executed through the policy have thrown 'a' handled exception - any of the exceptions handled by the policy. This is intentional behaviour.
The documentation here used to say 'a' handled exception: I've just updated it to say 'any' handled exception, to make that clearer. Thanks for the question.
If you wanted to construct a system that counts different faults (or groups of faults) separately for the purposes of circuit-breaking, you could achieve that by defining separate circuit-breaker policy instances for each fault (or group of faults) you wanted counted separately, and then nesting those circuit-breakers in a PolicyWrap.
I have a policy wrap with WaitAndRetry and CircuitBreaker policies, so, from my understanding the circuit only breaks when the exception is the same consecutively.
So, the
GetRandomException
method returns a SqlException randomly (40613, 40197, 40501 or 49918). So, my circuit breaker policy is configured to break the circuit after 3 exceptions, but I would expect that only happen if I throw, let's say the40613
SqlException in a row 3 times, but currently, it's breaking the circuit despite I'm throwing random exceptions.I don't know if I'm misunderstanding the usage or I have something wrong with the policies.
The text was updated successfully, but these errors were encountered: