Lock compact_index vendoring against parallel races#9579
Merged
Conversation
The vendored compact_index install ran without any coordination, so two test setups starting at once could both write into tmp/compact_index/ at the same time. The skip guard also checked a single file, which meant an interrupted download leaving only lib/compact_index.rb behind would be treated as a complete vendor tree on the next run. Take an exclusive file lock around the install and only skip the download once every expected file is present, removing the tree under the same lock when COMPACT_INDEX_REF forces a refresh. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents parallel test setup processes from racing while vendoring the compact_index source into tmp/compact_index, which can happen under make test-bundler-parallel.
Changes:
- Adds an exclusive file lock around vendored
compact_indexinstallation to serialize parallel setups. - Skips re-download only when all expected vendored files are present, and performs refresh (
COMPACT_INDEX_REF) under the same lock. - Ensures the shared temp root exists before creating the lock file.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+109
to
+114
| files.each do |path| | ||
| url = "https://raw.githubusercontent.com/rubygems/rubygems.org/#{ref}/#{path}" | ||
| target = target_root.join(path) | ||
| FileUtils.mkdir_p(File.dirname(target)) | ||
| File.write(target, URI.parse(url).open(&:read)) | ||
| end |
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.
What was the end-user or developer problem that led to this PR?
Following #9578, the vendored
compact_indexinstall runs as part ofinstall_test_depswith no coordination between processes.Under
make test-bundler-parallel, where each worker can reach this path independently, two setups starting at once can write intotmp/compact_index/simultaneously.What is your fix for the problem, implemented in this PR?
Take an exclusive file lock around the install and only skip the download once every expected file is present, removing the tree under the same lock when
COMPACT_INDEX_REFforces a refresh.Make sure the following tasks are checked