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
Lambda->>Persistence Layer: Get or set (id=event.search(payload))
367
+
activate Persistence Layer
368
+
Note right of Persistence Layer: Locked during this time. Prevents multiple<br/>Lambda invocations with the same<br/>payload running concurrently.
369
+
Lambda-->>Lambda: Run Lambda handler (event)
370
+
Lambda->>Persistence Layer: Update record with Lambda handler results
371
+
deactivate Persistence Layer
372
+
Persistence Layer-->>Persistence Layer: Update record with result
373
+
Lambda--xClient: Response not received by client
374
+
else retried request:
375
+
Client->>Lambda: Invoke (event)
376
+
Lambda->>Persistence Layer: Get or set (id=event.search(payload))
377
+
Persistence Layer-->>Lambda: Already exists in persistence layer. Return result
378
+
Lambda-->>Client: Response sent to client
379
+
end
380
+
```
381
+
<i>Idempotent sequence</i>
382
+
</center>
359
383
360
384
The client was successful in receiving the result after the retry. Since the Lambda handler was only executed once, our customer hasn't been charged twice.
361
385
@@ -367,7 +391,23 @@ The client was successful in receiving the result after the retry. Since the Lam
367
391
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**.
368
392
This means that new invocations will execute your code again despite having the same payload. If you don't want the record to be deleted, you need to catch exceptions within the idempotent function and return a successful response.
Lambda->>Persistence Layer: Get or set (id=event.search(payload))
402
+
activate Persistence Layer
403
+
Note right of Persistence Layer: Locked during this time. Prevents multiple<br/>Lambda invocations with the same<br/>payload running concurrently.
404
+
Lambda--xLambda: Run Lambda handler (event).<br/>Raises exception
405
+
Lambda->>Persistence Layer: Delete record (id=event.search(payload))
406
+
deactivate Persistence Layer
407
+
Lambda-->>Client: Return error response
408
+
```
409
+
<i>Idempotent sequence exception</i>
410
+
</center>
371
411
372
412
If you are using `idempotent_function`, any unhandled exceptions that are raised _inside_ the decorated function will cause the record in the persistence layer to be deleted, and allow the function to be executed again if retried.
0 commit comments