8000 Feature request: add support for `ReturnValuesOnConditionCheckFailure` in Idempotency · Issue #1784 · aws-powertools/powertools-lambda-java · GitHub
[go: up one dir, main page]

Skip to content
Feature request: add support for ReturnValuesOnConditionCheckFailure in Idempotency #1784
Closed
@dreamorosi

Description

@dreamorosi

Is your feature request related to a problem? Please describe.

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.

Describe the solution you'd like

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.

Describe alternatives you've considered

N/A

Additional context

N/A

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Coming soon

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0