How do I troubleshoot Lambda asynchronous invocation issues?

3 minute read
0

I’ve set up an AWS Lambda function to invoke asynchronously but the destination isn’t initiating. How do I fix this issue? When I invoke a Lambda function through the Lambda console does it get invoked synchronously or asynchronously? -or- How do I fix duplicated Lambda function invocations?

Resolution

When you asynchronously invoke a Lambda function and it fails, the following are possible causes:

  • Lambda doesn’t have permission to perform the actions included in the code.
  • The AWS service that invokes the Lambda function doesn’t have sufficient permissions.
  • The Lambda function is invoked synchronously.
  • Retry attempts were set to 0 in the asynchronous invocation configuration for a Lambda function.

Follow these steps to troubleshoot asynchronous invocation issues:

1.    Determine how the Lambda function is invoked. Is the function invoked using AWS CLI? Is the function invoked through an AWS service?

2.    Check whether the AWS service invokes the Lambda function synchronously or asynchronously.

3.    Invoke the Lambda function asynchronously by using the following command:

aws lambda invoke
  --function-name my-function 
      --invocation-type Event
          --cli-binary-format raw-in-base64-out
              --payload '{ "key": "value" }' response.json

See if a 202 status code is reported or if the command returns an error.

4.    Review the Lambda function's Amazon CloudWatch logs to see whether the duplicate invocations:

  • Have the same request ID or not.
  • Returned errors or timed out.

For more information, see How do I prevent duplicate Lambda function invocations?

5.    If the duplicate invocations have the same request ID and returned errors or timed out, configure error handling for asynchronous invocations. Using this configuration, you can control the number of retries the Lambda service can perform in case of failure.

For more information, see Error handling and automatic retries in AWS Lambda.

Note: Duplicate invocations with the same request ID that return errors or time out indicate that Lambda retried the function.

6.    If the duplicate invocations didn't return errors and didn’t time out, do the following:

  • Make sure that the Lambda function's code is idempotent and can handle the same messages multiple times.
  • Make sure that the Lambda function has its concurrency limit set high enough to handle the number of invocation requests it receives.
  • Identify and resolve any errors that the Lambda function returns.

For more information, see How do I troubleshoot Lambda function failures?

Note: If duplicate invocations are from the client side, the request IDs will be different.

7.    If you still can’t resolve the issue, open a case with AWS Support. Provide the following information in the case:

  • The Lambda function Amazon Resource Name (ARN).
  • The workflow on the Lambda function setup with all included services.
  • Details about whether the issue is intermittent or continuous.
  • Complete CloudWatch logs in .txt format from when the issue occurred. These CloudWatch logs are used to identify Lambda function errors that include timeout issues, init durations, and permissions issues.
  • The exact timestamp of the issue with the time zone or timestamp in UTC.

Note: AWS Support representatives don’t have access to customer CloudWatch logs due to security and privacy reasons.


Related information

Comparing Lambda invocation modes

Invoking Lambda functions

Introducing AWS Lambda Destinations

AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago