Skip to content

fix(failure_store): make circuit state transitions atomic using Redis pipeline - #10

Open
zerexei wants to merge 1 commit into
mainfrom
fix/circuit-state-transition-race-condition
Open

zerexei wants to merge 1 commit into
mainfrom
fix/circuit-state-transition-race-condition

Conversation

@zerexei

@zerexei zerexei commented Jul 20, 2026

Copy link
Copy Markdown
Member

Fixes #2

Summary

This PR refactors FailureStore.set_state() to execute state updates and cooldown key management atomically using Redis transaction pipelines (pipeline(transaction=True)).

Changes

  • Updated FailureStore.set_state() to wrap operations inside async with self.redis.pipeline(transaction=True) as pipe:.
  • Updated test helper FakeRedis across unit, integration, and chaos test suites to support pipeline().
  • Added unit test test_atomic_state_transition in tests/test_failure_store.py.

Verification

Ran uv run pytest — 50/50 tests passed.

@zerexei zerexei left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update docs if needed

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential race condition in circuit state transitions — should we prioritize consistency or availability? Description:

1 participant