Skip to content

Copy task: make ERROR_ACCESS_DENIED fail-fast Windows-only to fix macOS CoW retry resilience#13479

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/fix-macos-copy-task-resilience
Draft

Copy task: make ERROR_ACCESS_DENIED fail-fast Windows-only to fix macOS CoW retry resilience#13479
Copilot wants to merge 5 commits intomainfrom
copilot/fix-macos-copy-task-resilience

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

  • Changewave 18.6 guard on NativeMethodsShared.IsWindows (not macOS-specific)
  • Wave-disabled test covers all platforms
  • Added else branch in DoNotNormallyCopyOverReadOnlyFile asserting MSB3026 appears on non-Windows
  • ChangeWaves.md entry updated

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Hello @@copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo.

…OS CoW resilience

Agent-Logs-Url: https://github.com/dotnet/msbuild/sessions/18cc673e-cbf9-44ae-b6b8-585a38d7f0a1

Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix macOS Copy task for concurrent access failures Copy task: make ERROR_ACCESS_DENIED fail-fast Windows-only to fix macOS CoW retry resilience Apr 1, 2026
Copilot AI requested a review from rainersigwald April 1, 2026 14:43
@rainersigwald rainersigwald marked this pull request as ready for review April 1, 2026 18:20
Copilot AI review requested due to automatic review settings April 1, 2026 18:20
@rainersigwald
Copy link
Copy Markdown
Member

@copilot put the new behavior behind changewave 18.6.

@rainersigwald rainersigwald marked this pull request as draft April 1, 2026 18:22
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 adjusts the built-in Copy task’s retry behavior so that ERROR_ACCESS_DENIED only triggers the “fail-fast / no retry” path on Windows, improving resilience on macOS where EACCES can be transient under concurrent CoW/clone operations.

Changes:

  • Guard ERROR_ACCESS_DENIED fail-fast logic with NativeMethodsShared.IsWindows so non-Windows platforms fall back to the normal retry loop.
  • Update the DoNotNormallyCopyOverReadOnlyFile unit test so the “no retries logged” assertion is Windows-only.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Tasks/Copy.cs Limits the access-denied “throw immediately” behavior to Windows to allow retries on non-Windows.
src/Tasks.UnitTests/Copy_Tests.cs Adjusts the read-only overwrite test assertion to account for platform-dependent retry behavior.

Comment on lines +756 to 763
if (NativeMethodsShared.IsWindows)
{
// On Windows, ERROR_ACCESS_DENIED is not retried (it's a real ACL or r/o bit issue).
((MockEngine)t.BuildEngine).AssertLogDoesntContain("MSB3026");
}
// On non-Windows, access denied can be a transient lock (e.g. macOS CoW filesystem),
// so we retry; retries will ultimately fail for a genuinely read-only file.
}
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

On non-Windows this test no longer asserts anything about the new retry behavior (it only documents it in a comment). To keep the behavior change covered, add an assertion for the non-Windows path (e.g., that the retry warning code MSB3026 appears) or add a dedicated test that simulates an UnauthorizedAccessException(ERROR_ACCESS_DENIED) and verifies the Copy task enters the retry loop on non-Windows.

Copilot generated this review using guidance from repository custom instructions.
Agent-Logs-Url: https://github.com/dotnet/msbuild/sessions/c0adc714-f4a2-45f7-b322-46ac4bf8d409

Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 1, 2026

@copilot put the new behavior behind changewave 18.6.

Done in 9d82a6b. The non-Windows retry behavior is now gated behind ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave18_6). Added a DoNotRetryCopyOverReadOnlyFileWhenWave18_6Disabled test to verify the opt-out preserves old behavior, and added an entry to documentation/wiki/ChangeWaves.md.

…indows retry path

Agent-Logs-Url: https://github.com/dotnet/msbuild/sessions/1a824345-719b-4d22-b427-a6a732eb5ee7

Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy Task on macOS Copy-on-Write filesystems is not resilient to concurrent copies

3 participants