Skip to content

Increase grace period for BuildHost shutdown - #85881

Draft
mwiemer-microsoft wants to merge 2 commits into
mainfrom
mwiemer-fix-buildhost-shutdown-diagnostic
Draft

mwiemer-microsoft wants to merge 2 commits into
mainfrom
mwiemer-fix-buildhost-shutdown-diagnostic

Conversation

@mwiemer-microsoft

@mwiemer-microsoft mwiemer-microsoft commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

2026-10-01.12 roslyn-CI against main (expires ~2026-10-09, see attachments for persistent logs)

Runs fail sporadically if BuildHost shuts down slowly due to process load. This PR increases timeout from 500 ms to 5,000 ms (5 seconds) and adds a check for the BuildHost exit code on grace period expiry.

This is distinct from #85853: the failure addressed here comes from the process-disposal timeout during BuildHost restart/shutdown, not the manager's unexpected-disconnect callback.

[Error] [WorkspaceFailed] MSBuildWorkspace raised WorkspaceFailed with kind Failure: [BuildHost PID 104186] The BuildHost process is not responding.

Full attachment for indexing:

[12:53:24.438] [Information] [CreateNewProject] Creating binlog at /tmp/RoslynTests/a5e25f11-47f3-4b08-9d8e-9b6f5b574cc3/55686b6444f749a9a310dc70de0f5ccc/55686b6444f749a9a310dc70de0f5ccc.binlog
[12:53:24.589] [Trace] [BuildHost PID 104186] Message on stderr: info: BuildHost Runtime Version: .NET 11.0.0-rc.1.26425.128
[12:53:24.967] [Trace] [BuildHost PID 104186] Message on stderr: info: Registered MSBuild 11.0.100 instance at /opt/hostedtoolcache/dotnet/sdk/11.0.100-rc.1.26425.128
[12:53:24.973] [Trace] [BuildHost PID 104186] Message on stderr: info: Logging builds to /tmp/RoslynTests/a5e25f11-47f3-4b08-9d8e-9b6f5b574cc3/55686b6444f749a9a310dc70de0f5ccc/55686b6444f749a9a310dc70de0f5ccc.binlog
[12:53:25.139] [Trace] [BuildHost PID 104186] Message on stderr: info: Loading /tmp/RoslynTests/a5e25f11-47f3-4b08-9d8e-9b6f5b574cc3/55686b6444f749a9a310dc70de0f5ccc/55686b6444f749a9a310dc70de0f5ccc.csproj
[12:53:30.096] [Trace] [BuildHost PID 104186] Sending a Shutdown request to the BuildHost.
[12:53:30.197] [Trace] [BuildHost PID 104186] RpcClient has been shut down.
[12:53:30.205] [Trace] [BuildHost PID 104186] Message on stderr: info: RPC channel closed; process exiting.
[12:53:30.713] [Error] [WorkspaceFailed] MSBuildWorkspace raised WorkspaceFailed with kind Failure: [BuildHost PID 104186] The BuildHost process is not responding. Process output:
info: BuildHost Runtime Version: .NET 11.0.0-rc.1.26425.128
info: Registered MSBuild 11.0.100 instance at /opt/hostedtoolcache/dotnet/sdk/11.0.100-rc.1.26425.128
info: Logging builds to /tmp/RoslynTests/a5e25f11-47f3-4b08-9d8e-9b6f5b574cc3/55686b6444f749a9a310dc70de0f5ccc/55686b6444f749a9a310dc70de0f5ccc.binlog
info: Loading /tmp/RoslynTests/a5e25f11-47f3-4b08-9d8e-9b6f5b574cc3/55686b6444f749a9a310dc70de0f5ccc/55686b6444f749a9a310dc70de0f5ccc.csproj
info: RPC channel closed; process exiting.

[12:53:30.713] [Error] [BuildHost PID 104186] The BuildHost process is not responding. Process output:
info: BuildHost Runtime Version: .NET 11.0.0-rc.1.26425.128
info: Registered MSBuild 11.0.100 instance at /opt/hostedtoolcache/dotnet/sdk/11.0.100-rc.1.26425.128
info: Logging builds to /tmp/RoslynTests/a5e25f11-47f3-4b08-9d8e-9b6f5b574cc3/55686b6444f749a9a310dc70de0f5ccc/55686b6444f749a9a310dc70de0f5ccc.binlog
info: Loading /tmp/RoslynTests/a5e25f11-47f3-4b08-9d8e-9b6f5b574cc3/55686b6444f749a9a310dc70de0f5ccc/55686b6444f749a9a310dc70de0f5ccc.csproj
info: RPC channel closed; process exiting.

Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mwiemer-microsoft

Copy link
Copy Markdown
Member Author

Will investigate manually before sending to team

@mwiemer-microsoft mwiemer-microsoft changed the title Avoid reporting successful BuildHost shutdown as failure Avoid reporting slow BuildHost shutdown as failure Oct 2, 2026
@mwiemer-microsoft mwiemer-microsoft changed the title Avoid reporting slow BuildHost shutdown as failure Increase grace period for BuildHost shutdown Oct 2, 2026
@mwiemer-microsoft
mwiemer-microsoft marked this pull request as ready for review October 2, 2026 16:45
@mwiemer-microsoft
mwiemer-microsoft requested a review from a team as a code owner October 2, 2026 16:45
Copilot AI balanced review requested due to automatic review settings October 2, 2026 16:45
@mwiemer-microsoft

Copy link
Copy Markdown
Member Author

@RikkiGibson requesting review

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.

Copilot review overview

🟡 Changes recommended

The timeout path can silently kill a genuinely stuck BuildHost, and the tests do not exercise that path.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Extends BuildHost shutdown tolerance, but incorrectly treats RPC completion as proof of process exit.

Changes:

  • Increases shutdown grace period to five seconds.
  • Suppresses timeout failures after an acknowledged shutdown request.
  • Adds shutdown-related tests.
File Description
BuildHostProcessManager.cs Adjusts timeout and failure reporting.
BuildHostProcessManagerTests.cs Adds shutdown disposal tests.

Comment on lines +566 to +573
if (ShouldReportFailureOnShutdownTimeout(shutdownSucceeded))
{
LogProcessFailure();
}
else
{
_logger?.LogTrace("BuildHost did not exit after a successful shutdown request; terminating the process.");
}
Comment on lines +45 to +50
[Theory]
[InlineData(true, false)]
[InlineData(false, true)]
public void ShouldReportFailureOnShutdownTimeout(bool shutdownSucceeded, bool expected)
{
Assert.Equal(expected, BuildHostProcessManager.ShouldReportFailureOnShutdownTimeout(shutdownSucceeded));
[Theory]
[InlineData(true, false)]
[InlineData(false, true)]
public void ShouldReportFailureOnShutdownTimeout(bool shutdownSucceeded, bool expected)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we should necessarily be testing this. It seems like its just testing a log, and the log depends only on timeout and could just make this super flaky.

if (!_process.HasExited)
{
LogProcessFailure();
if (ShouldReportFailureOnShutdownTimeout(shutdownSucceeded))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this change actually necessary? Seems like we're just changing log behavior and not really anything else?

@mwiemer-microsoft
mwiemer-microsoft marked this pull request as draft October 2, 2026 18:32
@mwiemer-microsoft

Copy link
Copy Markdown
Member Author

(marking draft: reviewing value of this PR as a separate fix from #85853 and other related PRs)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants