-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: Race conditions with multiple downloads on the same layer #7422
Conversation
@@ -106,7 +107,7 @@ def download(self, layer: LayerVersion, force=False) -> LayerVersion: | |||
LOG.info("%s is already cached. Skipping download", layer.arn) | |||
return layer | |||
|
|||
layer_zip_path = layer.codeuri + ".zip" | |||
layer_zip_path = f"{layer.codeuri}_{uuid.uuid4().hex}.zip" | |||
layer_zip_uri = self._fetch_layer_uri(layer) | |||
unzip_from_uri( |
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.
quick question, but will we come across any issues when the Layer is unpacked into the same directory across different threads? I would imagine that this would be fine since the OS controls I/O, but wanted to check
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.
Oh it should be fine. This is what we want :)
Which issue(s) does this change fix?
Why is this change necessary?
Customer reports that when the SAM template contains multiple functions, some shared the same lambda layer,
local start-api
throw the exceptionThis is because there was a race condition when multiple layer_downloaders were running to build multiple functions concurrently. Some could finish downloading the file first and remove the .zip file, causing the other one failed to unzip.
How does it address the issue?
The fix is to ask each downloader to download into separate zip file (by adding the thread id to the file name), but the extracted folder remains the same.
What side effects does this change have?
Mandatory Checklist
PRs will only be reviewed after checklist is complete
make pr
passesmake update-reproducible-reqs
if dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.