Skip to content

Fix flaky test: retry binlog copy on IOException - #54831

Merged
MichaelSimons merged 1 commit into
mainfrom
michaelsimons/fix-binlog-file-lock-flaky-test
Jun 18, 2026
Merged

MichaelSimons merged 1 commit into
mainfrom
michaelsimons/fix-binlog-file-lock-flaky-test

Conversation

@MichaelSimons

Copy link
Copy Markdown
Member

Summary

Fixes #54817

The File.Copy for binlog upload to Helix can throw IOException when MSBuild hasn't fully released the file handle, causing test failures unrelated to the test logic.

Changes

  • New FileUtility.TryCopyFile (test/Microsoft.NET.TestFramework/Utilities/FileUtility.cs): A reusable utility that copies a file with retry-on-IOException and diagnostic logging:

    • If the destination already exists, skips the copy and logs a warning
    • Retries up to 3 times with increasing backoff (500ms, 1s, 1.5s) on IOException
    • On final failure, logs a warning without throwing
  • Updated TestCommand.Execute to use FileUtility.TryCopyFile for binlog uploads so transient file locks do not fail tests.

Testing

Binlog upload is diagnostic-only — copy failures will not fail the test.

Extract FileUtility.TryCopyFile that retries File.Copy on IOException
with backoff. If the destination already exists the copy is skipped
with a diagnostic log. If all retries are exhausted the failure is
logged as a warning without throwing.

Use TryCopyFile for binlog uploads in TestCommand so that transient
file locks (e.g. MSBuild still holding the binlog handle) do not fail
tests.

Fixes #54817

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 17, 2026 20:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses Helix test flakiness caused by transient IOException file locks when copying *.binlog files for upload by moving the binlog copy into a retrying helper and using it from TestCommand.Execute.

Changes:

  • Added FileUtility.TryCopyFile helper to copy a file with retry-on-IOException and non-fatal logging.
  • Updated TestCommand.Execute to use FileUtility.TryCopyFile for Helix binlog uploads so diagnostic upload failures don’t fail the test.

Reviewed changes

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

File Description
test/Microsoft.NET.TestFramework/Utilities/FileUtility.cs Introduces a retrying file-copy helper used for diagnostic binlog upload.
test/Microsoft.NET.TestFramework/Commands/TestCommand.cs Switches Helix binlog upload copy to the new retrying helper.

Comment thread test/Microsoft.NET.TestFramework/Utilities/FileUtility.cs
@MichaelSimons
MichaelSimons enabled auto-merge (squash) June 17, 2026 21:47
@MichaelSimons
MichaelSimons merged commit 291c8f6 into main Jun 18, 2026
27 checks passed
@MichaelSimons
MichaelSimons deleted the michaelsimons/fix-binlog-file-lock-flaky-test branch June 18, 2026 01:46
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 23, 2026
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.

Flaky test failure: msbuild.binlog file lock (IOException: being used by another process)

3 participants