-
Notifications
You must be signed in to change notification settings - Fork 90
Feature request: add support for ReturnValuesOnConditionCheckFailure
in Idempotency
#1784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey @dreamorosi, I just looked at this issue in more detail and will update some code to avoid making a second call to DynamoDB if the As a side note: Today, the Java runtime already avoids making a second to the DDB if the in-memory cache is enabled. Let me explain this process in more detail:
This is where we can improve by enabling To summarize, the behavior will be:
I am working on a PR for this now. |
Thanks for the explanation. In memory cache is good, but there's no guarantee that requests are served by the same Lambda execution environment, so it's still a good idea to add this. Looking forward to see the PR! |
I agree, and the in-memory cache is also optional. I created a PR for this feature here: #1821 I would love your review when you can find some time. |
Resolved by PR #1821 |
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 failImplementing 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:
IdempotencyItemAlreadyExistsError
we re throwWe could add something similar here.
Describe alternatives you've considered
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: