-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[ESM] Fix constantly triggering SQS back-off #12319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for jumping on this one quickly @gregfurman
It's unfortunate that GitHub didn't raise a conflict here. Next time, we can try to anticipate potentially conflicting changes (in this case the messages
logic changes significantly in #12002, which required a manual rebase and logic adjustment).
This fix addresses a performance issue affecting all Lambda ESM SQS users: Users might experience slow SQS polling with Lambda ESM because we are adding backoff (up to 10 seconds) after every polling iteration (in addition to the 1s inter-poll waiting time).
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 1h 29m 12s ⏱️ - 22m 46s Results for commit 55bb047. ± Comparison against base commit 4285fb1. This pull request removes 994 tests.
♻️ This comment has been updated with latest results. |
@joe4dev There is a flaky test (both against AWS and LocalStack) that can be explained by this line in the docs:
localstack/tests/aws/services/lambda_/event_source_mapping/test_lambda_integration_sqs.py Lines 392 to 394 in 4285fb1
Basically, we cannot assume that an ESM will always invoke a target Lambda with a very precise timeframe -- where AWS (and now LocalStack) dynamically adjusts this frequency based on traffic to the data source. I think the behavioural changes should remain, but we should keep an eye out for tests that assume invocations happen at precise intervals. |
tests/aws/services/lambda_/event_source_mapping/test_lambda_integration_sqs.py
Outdated
Show resolved
Hide resolved
352915b
to
55bb047
Compare
Motivation
This fixes an issue that causes our SQS poller to always trigger exponential backoff between poller calls instead of only when a response is empty or exception is raised. Currently, this bug is slowing down performance and should be merged ASAP.
Why did this happen?
GitHub's automatic rebase (which did not raise a merge conflict) caused our
if-else
conditional to change into afor-else
. Since theelse
block was where we raised a backoff exception, this has caused our poller to always raise an exception and signals the ESM worker to constantly back-off.See:
localstack/localstack-core/localstack/services/lambda_/event_source_mapping/pollers/sqs_poller.py
Line 196 in ceb6140
And:
localstack/localstack-core/localstack/services/lambda_/event_source_mapping/pollers/sqs_poller.py
Line 194 in 8859590
Changes