Skip to content

fix(circuit_breaker): treat a store error during probe election as a lost election - #8957

Open
sumedh-aerram wants to merge 1 commit into
aws-powertools:developfrom
sumedh-aerram:fix/circuit-breaker-probe-election-store-error
Open

sumedh-aerram wants to merge 1 commit into
aws-powertools:developfrom
sumedh-aerram:fix/circuit-breaker-probe-election-store-error

Conversation

@sumedh-aerram

Copy link
Copy Markdown
Contributor

Issue number:

closes #8954

Summary

Changes

When try_acquire_half_open raised a store error, such as DynamoDB throttling, the exception escaped @circuit_breaker and the in-process probe slot stayed claimed. That environment couldn't probe again until it was recycled. _route_open and _route_half_open now share _win_probe_election, which treats a store error as a lost election: it logs a warning, releases the probe slot, and routes the call to the open-circuit path. The docs' fail-open note covers this case.

User experience

During a throttling spike, calls get on_circuit_open or CircuitBreakerOpenError instead of a raw DynamoDB error, and the circuit can recover once the store does.

Verification

A new functional test drives @circuit_breaker with the DynamoDB store and a stubbed client, for the OPEN and expired-lease HALF_OPEN paths. It fails on develop and passes with the fix. Circuit breaker tests pass on Python 3.10 and 3.14. The full suite, ruff, mypy and ty pass. Not tested against real DynamoDB.

I used an AI assistant (Claude) to help write this change. I ran every check and reviewed the diff myself.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@sumedh-aerram
sumedh-aerram requested a review from a team as a code owner December 5, 2026 01:13
@boring-cyborg boring-cyborg Bot added documentation Improvements or additions to documentation tests labels Dec 5, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Dec 5, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Circuit breaker leaks _PROBES_IN_FLIGHT and crashes caller when try_acquire_half_open raises a store error

1 participant