Skip to content

feat(idempotency): Add support for ReturnValuesOnConditionCheckFailure in Idempotency. #1821

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

phipag
Copy link
Contributor

@phipag phipag commented Apr 22, 2025

Issue #, if available: #1784

Description of changes:

This feature avoids redundant DynamoDB calls in the Idempotency utility by making use of the ReturnValuesOnConditionCheckFailure option in the AWS SDK.

Instead of re-fetching a data record from the persistence store when a IdempotencyItemAlreadyExistsException is thrown, it attaches the offending data record to the exception so that it can be directly returned to the caller without making another DynamoDB call.

Note: In addition to unit tests, I ran E2E tests as well. Until E2E tests are restored in GitHub workflows, here is the output from running in my AWS account.

❯ mvn -Pe2e -B verify --file powertools-e2e-tests/pom.xml -Dtest="IdempotencyE2ET.java"
...
20:49:11.010 [main] INFO  software.amazon.lambda.powertools.testutils.Infrastructure - Uploading asset 839b70aab886d0655a55d0cd5db0219df16a020b1bdbcf192a3cfde01ca214d7.jar to cdk-hnb659fds-assets-********-eu-west-1
20:49:15.632 [main] INFO  software.amazon.lambda.powertools.testutils.Infrastructure - Deploying 'IdempotencyE2ET-c8f8877bbdc9' on account ********
20:50:16.714 [main] INFO  software.amazon.lambda.powertools.testutils.Infrastructure - Stack IdempotencyE2ET-c8f8877bbdc9 successfully deployed
20:50:33.978 [main] INFO  software.amazon.lambda.powertools.testutils.Infrastructure - Deleting 'IdempotencyE2ET-c8f8877bbdc9' on account ********
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 94.41 s -- in software.amazon.lambda.powertools.IdempotencyE2ET
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

Checklist

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@phipag phipag changed the title feature(idempotency): Add support for ReturnValuesOnConditionCheckFailure in Idempotency. feat(idempotency): Add support for ReturnValuesOnConditionCheckFailure in Idempotency. Apr 22, 2025
@phipag phipag added feature-parity Feature parity with python version and removed feature-request New feature or request labels Apr 22, 2025
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

Great work on the PR, I left two comments but you can resolve if you don't find them relevant.

Also TIL about transient - neat!

@dreamorosi
Copy link
Contributor

@phipag feel free to merge any time. No rush - just letting you know I'm ok with the comments and have resolved all the threads.

@phipag
Copy link
Contributor Author

phipag commented Apr 22, 2025

Awesome! Thanks for your prompt review. Merging now.

@phipag phipag merged commit 7b18029 into v2 Apr 22, 2025
10 checks passed
@phipag phipag deleted the phipag/issue1784 branch April 22, 2025 19:43
@github-project-automation github-project-automation bot moved this from Pending review to Coming soon in Powertools for AWS Lambda (Java) Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-parity Feature parity with python version idempotency size/L
Projects
Status: Coming soon
Development

Successfully merging this pull request may close these issues.

Feature request: add support for ReturnValuesOnConditionCheckFailure in Idempotency
2 participants