ServerlessChamp
ServerlessChamp

Reputation: 194

Duplicate Lambda Invocations in our system?

Just figured out that my Lambda function invocated twice with the same RequestID and the save Event, in our code, we assumed that any event comes once.

12:27:23
START RequestId: e511fe17-13b1-11e7-ab4f-5b2cfaa6339f Version: $LATEST
....
12:37:23
START RequestId: e511fe17-13b1-11e7-ab4f-5b2cfaa6339f Version: $LATEST

The 2nd invocation was after 600 seconds. Looks very strange...

Need help with the following things:

  1. Until we will resolve the problem, we want to know how much time it happens? Today we didn't found a way to measure the problem

  2. Any explanation for why this happens? It somehow can be a bug in our flow? maybe one of the integrations?

  3. Any workaround a way to know Inside the invocation code that this is request-id that already handled, and skips this

Currently it's causing a bug in our application, we count some of the user actions twice even they happened only once.

Upvotes: 1

Views: 2324

Answers (3)

Amit Tiwary
Amit Tiwary

Reputation: 797

AWS Lambda invokes at least once. If there is any error then it retries again. So make sure if there is any failure you are handling it and in case of success you are returning from the lambda function. I have seen that if you don't return from the handler function then lambda treats it as an error. I have added my learning here. it will help others to solve this problem.

Upvotes: 0

mantragya shrivastava
mantragya shrivastava

Reputation: 23

Just set retry count as zero and rerun . Most likely this occurs when your AWS Lambda get fails. I faced this issue while AWS lambda invocation as custom resource from AWS Cloud formation. I haven't controlled cfn response and ended up with twice invocation.

Upvotes: 2

jny
jny

Reputation: 8057

Most likely, the first invocation either fails or times out. In this case, lambda will re-try.

Upvotes: 0

Related Questions