Skip to content

Lock compact_index vendoring against parallel races#9579

Merged
hsbt merged 1 commit into
masterfrom
compact-index-install-lock
Jun 1, 2026
Merged

Lock compact_index vendoring against parallel races#9579
hsbt merged 1 commit into
masterfrom
compact-index-install-lock

Conversation

@hsbt
Copy link
Copy Markdown
Member

@hsbt hsbt commented Jun 1, 2026

What was the end-user or developer problem that led to this PR?

Following #9578, the vendored compact_index install runs as part of install_test_deps with no coordination between processes.

Under make test-bundler-parallel, where each worker can reach this path independently, two setups starting at once can write into tmp/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_REF forces a refresh.

Make sure the following tasks are checked

  • Describe the problem / feature
  • Write tests for features and bug fixes
  • Write code to solve the problem
  • Make sure you follow the current code style and write meaningful commit messages without tags

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>
Copilot AI review requested due to automatic review settings June 1, 2026 10:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_index installation 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
@hsbt hsbt enabled auto-merge June 1, 2026 11:15
@hsbt hsbt merged commit 0365a17 into master Jun 1, 2026
137 of 139 checks passed
@hsbt hsbt deleted the compact-index-install-lock branch June 1, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants