Feature: Idempotency calculate remaining invocation available time as part of the idempotency record #362
Closed
1 of 2 tasks
Labels
feature-request
New or enhancements to existing features
Use case
In the current implementation of Idempotency we don't have the InProgressExpiration timestamp. So currently if a lambda invocation expired there would be no way to retry it, when using the Idempotent attribute in the lambda handler or Idempotent attribute on another method
This field is required to prevent against extended failed retries when a Lambda function times out, Powertools for AWS Lambda (.NET) calculates and includes the remaining invocation available time as part of the idempotency record.
If a second invocation happens after this timestamp, and the record is marked as INPROGRESS, we will execute the invocation again as if it was in the EXPIRED state (e.g, expire_seconds field elapsed).
This means that if an invocation expired during execution, it will be quickly executed again on the next retry.
Solution/User Experience
When decorating the handler with Idempotent attribute we will do it automatically by getting the
RemainingTime
value from the ILambdaContext that is passed to the handler.RemainingTime
is the remaining execution time till the function will be terminated. At the time you create the Lambda function you set maximum time limit, at which time AWS Lambda will terminate the function execution.Information about the remaining time of function execution can be used to specify function behavior when nearing the timeout.
When using Idempotent attribute on another method to guard isolated parts of your code, you must use
RegisterLambdaContext
available in theIdempotency
static class to benefit from this protection.Here is an example on how you register the Lambda context in your handler:
Lambda request timeout diagram
Alternative solutions
No response
Acknowledgment
The text was updated successfully, but these errors were encountered: