Closed DavidBoike closed 2 months ago
Here is a hopefully simplified version https://github.com/Particular/NServiceBus.Transport.AzureServiceBus/pull/1057
Closing in favor of https://github.com/Particular/NServiceBus.Transport.AzureServiceBus/pull/1057
The circuit breaker's Success() method must be as close to a no-op as possible on the happy path, but when disarming in a multi-threaded environment still needs to run the disarm logic only once.
Previously, while querying values was done in a thread-safe way, a thread on the Failure method could pause while a Success() call ran to entirety, setting the failure count to 0, and ensuring that further calls to Success() would see a failure count of 0 and take no action, even though the arming action had been executed most recently.
This resulted in a scenario where no number of Success calls could undo the armedAction, unless another Failure call went first.