Skip to content

Feature request: Circuit breaker DynamoDB persistence, support single-table (composite key) reuse #8315

Description

@Iamrodos

Use case

CircuitBreakerDynamoDBPersistence lets us rename attributes but assumes a partition-key-only table. Our single-table design uses a composite key, and DynamoDB requires the sort key on every call so the persistence layer can't operate against it. It would be inert, failing open on every call (logged at WARNING) and never trips.

Solution/User Experience

Match the Idempotency utility's sort_key_attr + static_pk_value:

CircuitBreakerDynamoDBPersistence(
    table_name="my-single-table",
    key_attr="PK", sort_key_attr="SK", static_pk_value="CIRCUIT_BREAKER",
)

sort_key_attr stays optional, omit it and behavior is unchanged (partition-key-only, as today). Only when you supply it does the layer write the composite key: static_pk_value into the partition, circuit name into the sort key. No separate table, consistent with the rest of Powertools.

Happy to do a PR for this.

Alternative solution

A dedicated single-attribute table works but adds infra/IAM and breaks the single-table model, the same reason Idempotency added composite-key support.

Acknowledgment

Activity

  1. Iamrodos commented on Jun 29, 2026

    @Iamrodos
    ContributorAuthor

    Refs #8257 · shipped in v3.31.0

  2. xiaoranwang1452 commented on Jul 1, 2026

    @xiaoranwang1452

    Hi, I’m interested in contributing to this if it’s still available. I noticed this can mirror the existing Idempotency DynamoDBPersistenceLayer composite-key design. My plan would be to add optional sort_key_attr/static_pk_value support, keep current partition-key-only behavior unchanged, add Stubber-based functional tests for GetItem/PutItem/UpdateItem, and update the Circuit Breaker docs. If @Iamrodos is already working on it, I’m also happy to collaborate or pick another issue.

  3. leandrodamascena commented on Jul 1, 2026

    @leandrodamascena
    Contributor

    Thanks a lot @Iamrodos. This makes sense and you're right about the current limitation. CircuitBreakerDynamoDBPersistence only ever uses the partition key, so against a composite-key table every call would fail and the breaker would fail open on each invocation and never trip. Exactly what you described.

    One thing to watch when implementing: the circuit breaker doesn't only do get_item. It also does a conditional put_item for the half-open probe election and an update_item on state changes. The composite key has to be threaded through all three paths (including the conditional-write key), not just the read, otherwise it'll half-work.

    @xiaoranwang1452 happy to have you collaborate with this issue. Please include Stubber-based tests for get/put/update in both modes and a docs update.

  4. Iamrodos commented on Jul 1, 2026

    @Iamrodos
    ContributorAuthor

    PR submitted #8316

    @xiaoranwang1452 would appreciate your eye over it to ensure it meets the expectations of your use case.

  5. powertools-for-aws-oss-automation commented on Jul 2, 2026

    @powertools-for-aws-oss-automation

    Warning

    This issue is now closed. Please be mindful that future comments are hard for our team to see.
    If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

  6. added
    pending-releaseFix or implementation already in dev waiting to be released
    and removed
    triagePending triage from maintainers
    on Jul 2, 2026
  7. added a commit that references this issue on Jul 5, 2026
    cb6f906
  8. github-actions commented on Jul 13, 2026

    @github-actions
    Contributor

    This is now released under 3.31.1 version!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions