fix: Fix deadlock when snap start and using secret for api key#853
Merged
fix: Fix deadlock when snap start and using secret for api key#853
Conversation
f6132a7 to
bc99e51
Compare
lym953
commented
Sep 18, 2025
| fn load_configs(start_time: Instant) -> (AwsConfig, Arc<Config>) { | ||
| // First load the AWS configuration | ||
| let aws_config = AwsConfig::from_env(start_time); | ||
| let aws_credentials = AwsCredentials::from_env(); |
Contributor
Author
There was a problem hiding this comment.
No need to load credentials from main()
| }; | ||
|
|
||
| let aws_credentials_read = aws_credentials.read().await; | ||
| let mut aws_credentials = AwsCredentials::from_env(); |
Contributor
Author
There was a problem hiding this comment.
Load it as needed in resolve_secrets(), which is called lazily.
This was
linked to
issues
Sep 18, 2025
duncanista
approved these changes
Sep 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a Lambda (1) uses snap start, and (2) specifies Datadog API key using
DD_API_KEY_SECRET_ARN, the extension will encounter a deadlock. For aRwLock, the extension first gets a read lock:datadog-lambda-extension/bottlecap/src/secrets/decrypt.rs
Line 45 in daf633d
then tries to get a write lock:
datadog-lambda-extension/bottlecap/src/secrets/decrypt.rs
Line 65 in daf633d
which never finishes. This causes the function to time out.
This bug was introduced in #717.
This PR
Fix this bug by removing the
RwLockusage.AwsCredentialis only created and used once inresolve_secrets(), andresolve_secrets()is only called once, so there's no need to protect this struct with a lock.Testing
Tested on a Lambda with:
DD_API_KEY_SECRET_ARNBefore:
After:
Notes
Jira: https://datadoghq.atlassian.net/browse/SLES-2482