I have an SQS queue and a lambda as event source mapping for that queue. The lambda’s job is to parse some data from an S3 file in batches of 100. There are 10000+ entries in this file.
What I do is:
- Process the 100 rows
- Create a new queue job to process the next 100 by sending start/end parameters.
The process works great for 1600 entries and fails everytime exactly there. My last log entry which logs the sending as well as the metadata from SQS send command as well as the successful end of the lambda is this:
2024/06/30/[$LATEST]82e77466cf99479ca05c453e6da39436 2024-06-30T00:25:39.579000 {
"timestamp": "2024-06-30T00:25:39.579Z",
"level": "INFO",
"requestId": "2035819e-7b43-5e5f-9d0a-df64dcbed81a",
"message": {
"message": "Processing batch 1601-1700 of contacts-full16.csv",
"data": {
"$metadata": {
"httpStatusCode": 200,
"requestId": "9b5e2cfe-21cd-5649-9ade-7204898e4803",
"attempts": 1,
"totalRetryDelay": 0
},
"MD5OfMessageAttributes": "793a908cbea235c2c3fbfed4b9ee333a",
"MD5OfMessageBody": "c98b6d9c345a46fccf6d6cc6d92e99e9",
"MessageId": "99a6d3bc-d0b3-41cd-882f-28ffc3064dd0"
}
}
}
2024/06/30/[$LATEST]82e77466cf99479ca05c453e6da39436 2024-06-30T00:25:39.581000 {
"time": "2024-06-30T00:25:39.581Z",
"type": "platform.report",
"record": {
"requestId": "2035819e-7b43-5e5f-9d0a-df64dcbed81a",
"metrics": {
"durationMs": 50593.656,
"billedDurationMs": 50594,
"memorySizeMB": 512,
"maxMemoryUsedMB": 145
},
"tracing": {
"spanId": "15844fe56191b17e",
"type": "X-Amzn-Trace-Id",
"value": "Root=1-6680a5d0-5d097410faf01195360c7e44;Parent=5c5e05fe243ddd01;Sampled=1"
},
"status": "success"
}
}
The lambda exited with “success” just like it did 15-16 times before. Looking at my queue it says 1 message in flight, nothing in DLQ.
Here’s my CF (SAM):
Resources:
DeadLetterQueue:
Type: AWS::SQS::Queue
UpdateReplacePolicy: Delete
DeletionPolicy: Delete
SQSQueue:
Type: AWS::SQS::Queue
UpdateReplacePolicy: Delete
DeletionPolicy: Delete
Properties:
QueueName: my-queue
MessageRetentionPeriod: 86400
VisibilityTimeout: 1800
RedrivePolicy:
deadLetterTargetArn: !GetAtt DeadLetterQueue.Arn
maxReceiveCount: 3
SQSQueueHandler:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/handlers/
Handler: sync.lambdaHandler
Runtime: nodejs20.x
MemorySize: 512
Timeout: 300
Policies:
- AmazonSQSFullAccess
LambdaFunctionEventSourceMapping:
Type: AWS::Lambda::EventSourceMapping
Properties:
BatchSize: 10
Enabled: true
EventSourceArn: !GetAtt SQSQueue.Arn
FunctionName: !GetAtt SQSQueueHandler.Arn
I have tried this 4 times and it always stops at that same exact point – I am wondering if there is some cap/limit of how many times this will work – perhaps it is waiting now but not sure. I don’t see any info on my console nor through searching that indicates there would be a parameter that would limit this.
Any ideas? I’ve even placed dummy code for the row processing to no avail – it seems to work great except for the fact that the 16th SQS request never gets picked up by the lambda.