You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/utilities/idempotency.md
+10-16Lines changed: 10 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -283,29 +283,23 @@ Imagine the function runs successfully, but the client never receives the respon
283
283
284
284
### Lambda timeouts
285
285
286
-
???+ note
287
-
This is automatically done when you decorate your Lambda handler with [@idempotent decorator](#idempotent-decorator).
288
-
289
-
To prevent against extended failed retries when a [Lambda function times out](https://aws.amazon.com/premiumsupport/knowledge-center/lambda-verify-invocation-timeouts/){target="_blank"},
290
-
Powertools for AWS Lambda (Python) calculates and includes the remaining invocation available time as part of the idempotency record.
291
-
292
-
???+ example
293
-
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).
294
-
295
-
This means that if an invocation expired during execution, it will be quickly executed again on the next retry.
286
+
By default, we protect against [concurrent executions](#handling-concurrent-executions-with-the-same-payload) with the same payload using a locking mechanism. However, if your Lambda function times out before completing the first invocation it will only accept the same request when the [idempotency record expire](#expiring-idempotency-records).
296
287
297
-
???+ important
298
-
If you are only using the [@idempotent_function decorator](#idempotent_function-decorator) to guard isolated parts of your code,
299
-
you must use `register_lambda_context` available in the [idempotency config object](#customizing-the-default-behavior) to benefit from this protection.
300
-
301
-
Here is an example on how you register the Lambda context in your handler:
288
+
To prevent extended failures, use **`register_lambda_context`** function from your idempotency config to calculate and include the remaining invocation time in your idempotency record.
302
289
303
290
=== "Registering the Lambda context"
304
291
305
-
```python hl_lines="11 20"
292
+
> This is unnecessary for [`@idempotent` decorator](#idempotent-decorator), as it captures the Lambda context from your handler function.
If a second invocation happens **after** this timestamp, and the record is marked as `INPROGRESS`, we will run the invocation again as if it was in the `EXPIRED` state.
300
+
301
+
This means that if an invocation expired during execution, it will be quickly executed again on the next retry.
302
+
309
303
### Handling exceptions
310
304
311
305
If you are using the `idempotent` decorator on your Lambda handler, any unhandled exceptions that are raised during the code execution will cause **the record in the persistence layer to be deleted**.
0 commit comments