-
Notifications
You must be signed in to change notification settings - Fork 401
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
feat(idempotency): handle lambda timeout scenarios for INPROGRESS records #1387
feat(idempotency): handle lambda timeout scenarios for INPROGRESS records #1387
Conversation
de71882
to
a4f8ce7
Compare
Codecov Report
@@ Coverage Diff @@
## develop #1387 +/- ##
========================================
Coverage 99.88% 99.89%
========================================
Files 119 119
Lines 5429 5456 +27
Branches 620 624 +4
========================================
+ Hits 5423 5450 +27
Misses 2 2
Partials 4 4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
early comments before I resume reading it after lunch. At a quick glance, the pieces that would benefit the most now are:
- 1/ Comments on the formula you're using since I saw Lambda context giving us milliseconds, then epoch (sensible for comparison), then type coercion to string (?) - sounds like we could reuse the milliseconds instead of wall clock time. Also,
datetime.datetime.now()
uses timezone offset too, instead of a safe non-backward timestamp like time.monotonic - 2/ I think the Update Expression would benefit to having the new one as a separate variable, then use f-string to combine them and make it more readable (which conditional is for which use case)
aws_lambda_powertools/utilities/idempotency/persistence/base.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/idempotency/persistence/base.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/idempotency/persistence/dynamodb.py
Outdated
Show resolved
Hide resolved
…d split diag section Signed-off-by: heitorlessa <[email protected]>
I've pushed an updated doc with the following changes:
|
…to feat/expire-inprogress * rubenfonseca/feat/expire-inprogress: chore(idempotency): no need to update expire on update chore(documentation): addressed comments chore(idempotency): simplified strings chore(idempotency): address comments chore(docs): add documentation to method chore(idempotency): added tests for handle_for_status
…tools-python into develop * 'develop' of https://github.com/awslabs/aws-lambda-powertools-python: feat(idempotency): handle lambda timeout scenarios for INPROGRESS records (#1387) chore(deps): bump jsii from 1.57.0 to 1.63.1 (#1390) chore(deps): bump constructs from 10.1.1 to 10.1.59 (#1396) chore(deps-dev): bump flake8-isort from 4.1.1 to 4.1.2.post0 (#1384) docs(examples): enforce and fix all mypy errors (#1393) chore(ci): drop 3.6 from workflows (#1395)
Issue number: #1038
Summary
Expire in-progress invocations caused by Lambda time outs.
Changes
During an invocation, we try to figure out how much time the Lambda invocation has before it expires, and save it on the idempotency record together will all the other fields.
When a new invocation with the same key arrives, we check against this timestamp to see if there's any
INPROGRESS
invocation past the timeout timestamp. If there is, we allow the invocation to be retried.We also moved the squence diagrams of the idempotency module in documentation to mermaid.js.
Caveats
@idempotent
decorator, because right now it's the only way to access the Lambda context to get the remaining time left. I've added aregister_lambda_context
to theIdempotencyConfig
class as a workaroundUser experience
Before: if a Lambda invocation times out, the invocation will get stuck until the idempotency record expires (default = 1 hour).
After: if a Lambda invocation times out, the invocation will be tried again on the next retry.
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.
View rendered docs/utilities/idempotency.md