fix: S3Downloader - improve concurrent behavior#3327
Merged
Conversation
Contributor
Coverage report (amazon_bedrock)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
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.
Related Issues
S3Downloadercache races cause corrupt downloads under concurrent pipeline runs #3294Proposed Changes:
_download_filewrites straight to the final cache path, so a concurrent reader can observe a partial PDF mid-write -> download to a temp path and finally move the file to its expected location (no more partial files)if file_path.is_file(): file_path.touch(). Between the condition and thetouchcommand, another downloader running could potentially delete the file andtouchrecreates an empty one. -> useutimethat does not create the file but only updates timestampHow did you test it?
CI
Notes for the reviewer
Another major race condition (
_cleanup_cacheonly protects files referenced by the current run, so it can delete files another in-flight run is about to read) is not touched by this PR because it's hard to avoid. A workaround is settingmax_cache_sizeto a high number of files (similar to disabling cache deletion).Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.