mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-16 06:07:17 -05:00
[PR #1940] [MERGED] fix(mlperf-edu): dataset download race on shared fixed temp filename #36550
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1940
Author: @Shashank-Tripathi-07
Created: 7/7/2026
Status: ✅ Merged
Merged: 7/10/2026
Merged by: @profvjreddi
Base:
dev← Head:fix/assets-download-race-condition📝 Commits (1)
e0e43e6fix(mlperf-edu): dataset download race on shared fixed temp filename📊 Changes
1 file changed (+24 additions, -17 deletions)
View changed files
📝
mlperf-edu/src/mlperf/assets.py(+24 -17)📄 Description
Summary
_download()wrote directly to the caller-provided destination -- a fixed.downloadtemp path with no PID/UUID component (tmp = raw.with_suffix(".download"), used identically byensure_tinyshakespeare,ensure_cifar100,ensure_movielens_100k).urlretrieve/curlto the identical path with independent file handles -- a slower writer's in-progress download could be clobbered mid-write by the other process before either side renamed to the final path.Fix
Download to a process- and call-unique temp file first (
destination.download.<pid>.<uuid8>.part), then atomically replace the destination. Concurrent callers now only race on the final atomic rename (last-writer-wins, both writes are complete valid downloads), never on the write itself.Test plan
python -m py_compilepasses on the edited file..parttemp files remain.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.