Repository navigation
Description
Describe the bug
When two background: true steps use local composite actions that both
reference the same action at the same ref, the runner downloads that action
twice at the same moment, into the same _actions/<owner>/<repo>/<ref>
directory. One of the steps fails during "Prepare all required actions",
before any of its own steps run.
We hit this in roughly a quarter of our recent failed CI runs, with errors
that vary from run to run:
##[error]Could not find file '/home/runner/work/_actions/actions/cache/55cc8345863c7cc4c66a329aec7e433d2d1c52a9/RELEASES.md'.
##[error]Directory not empty : '/home/runner/work/_actions/actions/cache/55cc8345863c7cc4c66a329aec7e433d2d1c52a9'
##[error]The process cannot access the file '/home/runner/work/_actions/actions/cache/55cc8345863c7cc4c66a329aec7e433d2d1c52a9/RELEASES.md' ...
Both downloads show up in the log within a few hundred milliseconds of each
other:
11:41:52.2047453Z Waiting for all background step(s) to complete: Setup uv environment, Setup mise, Wait for db
11:41:52.2067716Z Download action repository 'actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9' (SHA:55cc8345863c7cc4c66a329aec7e433d2d1c52a9)
11:41:52.5696546Z Download action repository 'actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9' (SHA:55cc8345863c7cc4c66a329aec7e433d2d1c52a9)
11:41:52.8343784Z ##[error]Could not find file '/home/runner/work/_actions/actions/cache/55cc8345863c7cc4c66a329aec7e433d2d1c52a9/RELEASES.md'.
To reproduce
steps:
- uses: actions/checkout@v7
- name: Setup A
uses: ./.github/actions/setup-a # composite, uses actions/cache@<sha>
background: true
- name: Setup B
uses: ./.github/actions/setup-b # composite, uses actions/cache@<sha>
background: true
- wait-all:It is intermittent, because the two downloads have to overlap.
Expected behavior
An action that several concurrent steps need is downloaded once, or the
downloads are serialised, so that no step sees a half-written directory.
Cause
Actions used inside a local composite action are prepared when the composite
step starts
(ActionRunner.cs#L92),
not during job setup. DownloadRepositoryActionAsync only skips the download
when the <dir>.completed watermark exists
(ActionManager.cs#L1195).
Otherwise it extracts the archive into a unique temp directory, then deletes
the shared destination directory
(#L1362),
copies the files into it
(#L1374)
and writes the watermark
(#L1378).
Nothing stops two background steps from running the delete and copy on the
same directory at once. That matches all three errors above. The same code is
unchanged on main.
Workaround
Add a foreground top-level step that uses the shared action before the
background steps. Top-level actions are downloaded during job setup
(JobExtension.cs#L299),
which writes the watermark, so the composites skip the download:
- name: Pre-download actions/cache for the background steps
uses: actions/cache/restore@<same sha>
with:
path: .pre-download-actions-cache
key: pre-download-actions-cache
lookup-only: trueRunner version and platform
Runner 2.337.0, GitHub-hosted ubuntu-24.04 (image 20261015.610).
Related
#4789 reports a different race between parallel composite actions, on
GITHUB_STATE handling.
Activity