Lambda is triggering multiple times and it sends duplicate emails

0

Hi,

I've configured a Lambda to send emails via ses using nodeJS and it is being triggered via pg_cron - a postgres CRON-based Lambda invocation.

Problem that I'm facing is multiple invocation of same lambda is happening in seconds even if my frequency of invoking lambda function is 2 mins or 5 mins. This is causing duplicate emails at destination and seems intermittent too.

Any help or suggestion would be helpful.

Thank you!

3 Answers
0

There could be two root cause of your problem.

  1. SES is sending duplicate emails. Although SES is designed to send only one copy of the message but if in case it don't receive an acknowledgement from the recipient email server then it treat it as a failure and would do a retry of that message. please check for the duplicate message if the message id is same or not.
  2. Duplicate invocation of lambda. first check your cron scheduler. second, review your cloud watch logs check if the duplicate invocation has same request id? if it is a duplicate invocation , use this configuration to handle the retries - https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-async-errors
AWS
answered a year ago
  • I've checked the logs and the request-id seems different, check the image I posted. Any thoughts?

0

Another possibility is that your Lambda function is raising an exception after sending email, triggering the Lambda service to retry. This would be visible in the Lambda function logs which you've probably already checked though.

EXPERT
answered a year ago
  • check the image I posted below. It just took seconds in the next invocations though I have configured 2 min schedule

0

Enter image description here

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions