bug: SQS FIFO queue returns messages from a group where the first message in that group is not visible
Is there an existing issue for this?
- [x] I have searched the existing issues
Current Behavior
- Create a FIFO queue with a 10 second visibility timeout
- Publish 3 messages to it with the same group ID
- Receive up to 5 messages (all 3 messages come back)
- Set the visibility timeout of the first message to 15 seconds
- Wait 12 seconds
- Receive messages again
Messages 2 and 3 are received, despite message 1 not being visible.
Expected Behavior
The behaviour of a FIFO queue is such that no messages in a group should be received if the first message in that group is not visible.
It should be expected that no messages will be received after 12 seconds. After 15 seconds, when the first message is visible again, all messages should be received.
If you run the script below against aws SQS directly, it works as intended.
How are you starting LocalStack?
With a docker run command
Steps To Reproduce
# Deps for this script
apt-get install jq
# Create fresh queue
awslocal sqs delete-queue --queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/foo.fifo
awslocal sqs create-queue --attributes FifoQueue=true,VisibilityTimeout=10,MessageRetentionPeriod=14400 --queue-name foo.fifo
# Send 3 messages
awslocal sqs send-message --queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/foo.fifo --message-body foo --message-group-id 1 --message-deduplication-id foo
awslocal sqs send-message --queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/foo.fifo --message-body bar --message-group-id 1 --message-deduplication-id bar
awslocal sqs send-message --queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/foo.fifo --message-body bar --message-group-id 1 --message-deduplication-id baz
# Receive all messages
awslocal sqs receive-message --queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/foo.fifo --max-number-of-messages 5 | tee /tmp/fifo-bug-recv
# ReceiptHandle of first message
id=$(cat /tmp/fifo-bug-recv | jq -r '.Messages[0].ReceiptHandle')
# Set visibility timeout of first message to 15 seconds
awslocal sqs change-message-visibility --queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/foo.fifo --visibility-timeout 15 --receipt-handle $id
# Wait 12 seconds
sleep 12
# Get all messages again
# We should get no messages because the first one of this group is invisible
# Instead, we get 2 messages
awslocal sqs receive-message --queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/foo.fifo --max-number-of-messages 5
Environment
- OS: MacOS (with Docker)
- LocalStack:
LocalStack version: 4.3.1.dev2
LocalStack Docker image sha: 4e2528d7c93a5cf9657283772aa516ff9d56bc6255b8b69b9c61c5eebf17f4f9
LocalStack build date: 2025-03-28
LocalStack build git hash: 90ccf60d5
Anything else?
No response
Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our contributing guide.
📋 Copied to lazarkanelov/localstack#7