Recursive Loop error stopping lambda execution

0

Hi, I have a use case where a lambda L1 triggers lambda L2 again via SQS msg with a small delay. I need to keep doing this untill a specific time which I am maintaining in my Logic. However Lambda execution is being stopped at 16 executions sighting recursive loop error. How can I resolve this issue?

Also, if I use Step Function to design the process.. would it help is fixing this issue?

已提問 10 個月前檢視次數 498 次
2 個答案
1

Yes, I think Step Functions would be useful for architectures that loop Lambda.
The following documents may be helpful in setting up loops.
https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-create-iterate-pattern-section.html

Also, I believe the following update caused it to stop after the 16th loop.
https://aws.amazon.com/about-aws/whats-new/2023/07/aws-lambda-detects-recursive-loops-lambda-functions/?nc1=h_ls

It is also recommended that billing alerts be set up when setting up a large number of loops, as they can result in large fees.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html

profile picture
專家
已回答 10 個月前
profile picture
專家
已審閱 10 個月前
0

Hi, it seems that you know exactly what you do these recursive calls.

In that case you can allow them without a stop at 16: see https://aws.amazon.com/blogs/compute/detecting-and-stopping-recursive-loops-in-aws-lambda-functions/

Disabling recursion detection
You may have valid use-cases where Lambda recursion is intentional as part 
of your design. In this case, use caution and implement suitable guardrails to prevent 
unexpected charges to your account. To learn more about best practices for using recursive 
invocation patterns, see Recursive patterns that cause run-away Lambda functions in the 
AWS Lambda Operator Guide.

This feature is turned on by default to stop recursive loops. To request turning it off for your 
account, reach out to AWS Support.

Best,

Didier

profile pictureAWS
專家
已回答 10 個月前
profile picture
專家
已審閱 10 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南