Fix race condition when pulling manifest with duplicate digests#688
Merged
amisevsk merged 1 commit intokitops-ml:mainfrom Jan 15, 2025
Merged
Fix race condition when pulling manifest with duplicate digests#688amisevsk merged 1 commit intokitops-ml:mainfrom
amisevsk merged 1 commit intokitops-ml:mainfrom
Conversation
When a manifests contains two layers with the same digest, pulling that ModelKit can fail if we try to download both (identical) layers simultaneously. The first download to win the race moves the file from the ingest/ directory to blobs/sha256/, and the second fails as the source file does not exist. To avoid this, we pull each digest only once.
gorkem
approved these changes
Jan 12, 2025
| var semErr error | ||
| // In some cases, manifests can contain duplicate digests. If we try to concurrently pull the same digest | ||
| // twice, a race condition will cause the pull the fail. | ||
| pulledDigests := map[string]bool{} |
Member
There was a problem hiding this comment.
this can be a preallocated map
pulledDigests := make(map[string]bool, len(toPull))
Contributor
Author
There was a problem hiding this comment.
It could, but in the case we're trying to solve this would be overallocating -- this is a set used to check whether we've seen each element before. With v0.4.0, we can create ModelKits that have the same layer dozens of times (e.g. empty readme.md files in different directories)
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.
Description
When a manifests contains two layers with the same digest, pulling that ModelKit can fail if we try to download both (identical) layers simultaneously. The first download to win the race moves the file from the ingest/ directory to blobs/sha256/, and the second fails as the source file does not exist.
To avoid this, we pull each digest only once.
Linked issues
Closes #687