Fix Lambda async invocation queue namespace#10831
Conversation
S3 Image Test Results (AMD64 / ARM64) 2 files 2 suites 3m 12s ⏱️ Results for commit 6445b95. ♻️ This comment has been updated with latest results. |
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 1h 40m 16s ⏱️ + 3m 26s Results for commit 6445b95. ± Comparison against base commit 9d80628. This pull request removes 24 and adds 62 tests. Note that renamed tests count towards both.This pull request skips 4 and un-skips 3 tests.♻️ This comment has been updated with latest results. |
|
removing myself as reviewer as i was added only because of the config.py change |
dfangl
left a comment
There was a problem hiding this comment.
I think this is a good solution for now.
We should definitely tackle the lambda function deletion locks and the aborted invocations soon!
I just had some minor questions regarding some comments, otherwise approved from my side :)
| def latest(self) -> FunctionVersion: | ||
| return self.versions["$LATEST"] | ||
|
|
||
| # HACK to model a volatile variable that should be ignored for persistence |
There was a problem hiding this comment.
I am also not 100% satisfied with this hack, but I think for now it is the best solution. Let's hope we can find a way to get by without this hack in the future :)
There was a problem hiding this comment.
yeah, pretty ugly hack 😢
We currently don't have a Python object such as the VersionManager at function level. Alternative hacks:
- Use a dict to track them in the lambda service, but passing it down into the event managers is gonna be awkward
- Add it to the version manager of a specific version (e.g., v1, $LATEST is annoying because then it needs to migrate)
Motivation
Addresses #10280
Re-creating a Lambda function immediately after deleting it, triggers a race condition and deletes the internal async invoke queue. This causes continuous error logs and breaks async invokes.
The namespace clash also causes further issues because queued invokes can get deleted.
Changes
test_recreate_functionto reproduce the reported function recreate issuetest_function_update_during_invoketo validate the AWS behavior of function updates during a running invocation => Currently broken on LocalStacktest_async_invoke_queue_upon_function_updateto validate the queuing behavior of async invokes when a function update happens => kinda works but the first invoke fails and gets retried due function updates aborting all running invokes (even for $LATEST)Unrelated changes sneaked in:
lambda_servicebacklink in Lambda service manager (missing declaration cleanup from this PR)Testing
State pickling testing whether the
instance_idattribute is persisted or not:tests.aws.services.lambda_.test_lambda.TestLambdaCleanup.test_recreate_functionwith a breakpoint at the end of the testslocalstack-pro state export --format json lambda-stateDiscussion