Skip to content

Feature request: add support for ReturnValuesOnConditionCheckFailure in Idempotency #803

Open
@dreamorosi

Description

@dreamorosi

Use case

When working with the Idempotency utility, the current implementation performs 2 operations: one write and one read whenever it encounters an idempotent request after the first time.

This happens because the implementation hinges on making an optimistic write to set the request as "in progress" while using a condition expression. When there's already another item, the condition expression will fail and the error will be interpreted as a request that should not be retried.

When this happens, the utility then goes on by reading the existing previously inserted error. The entire flow I just described is represented here in this diagram.

Several months ago DynamoDB announced the ability to specify a ReturnValuesOnConditionCheckFailure parameter that allows the call to automatically return the item that made the write fail

Implementing this mechanism would allow the utility to bypass the second read and thus improve performance and materialize cost savings for end customers.

Solution/User Experience

Currently the feature is supported in both the TypeScript and Python versions of Powertools for AWS. Here's the implementation we have in TypeScript for example:

  • here is where we use the new flag
  • here is where we handle the conditional check failed error, get the item, and pass it to the IdempotencyItemAlreadyExistsError we re throw
  • here is where we conditionally use that idempotency record if present, or default to the old behavior of reading it in a separate operation

We could add something similar here.

Alternative solutions

N/A

Acknowledgment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions