Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSBuild Server fallback mechanism doesn't work when Mutex throws exception #7993

Closed
MichalPavlik opened this issue Sep 21, 2022 · 1 comment · Fixed by #8000 or #8024
Closed

MSBuild Server fallback mechanism doesn't work when Mutex throws exception #7993

MichalPavlik opened this issue Sep 21, 2022 · 1 comment · Fixed by #8000 or #8024

Comments

@MichalPavlik
Copy link
Member

MichalPavlik commented Sep 21, 2022

The MSBuildClientApp.TryLaunchServer method returns false in case server node couldn't be started (and build is then done without server). However, there was reported issue, when mutex logic failed with unhandled IOException.

Unhandled exception: System.IO.IOException: Connection timed out : 'Global\msbuild-server-launch-BSVTwDRbqiZ8pAK9bysU7lvA2UC4yhR_+Bc8sTbm8Jw'
         at System.Threading.Mutex.CreateMutexCore(Boolean initiallyOwned, String name, Boolean& createdNew)
         at Microsoft.Build.Experimental.MSBuildClient.TryLaunchServer()
         at Microsoft.Build.Experimental.MSBuildClient.Execute(CancellationToken cancellationToken)
         at Microsoft.Build.CommandLine.MSBuildClientApp.Execute(String[] commandLine, String msbuildLocation, CancellationToken cancellationToken)
         at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
         at Microsoft.DotNet.Cli.Utils.MSBuildForwardingAppWithoutLogging.ExecuteInProc(String[] arguments)

Hotfix should be easy - insert mutex logic to existing try/catch block. We should also find out why is it time-outing.

dotnet/runtime#75391
dotnet/runtime#75867

@MichalPavlik MichalPavlik added needs-triage Have yet to determine what bucket this goes in. performance bug and removed needs-triage Have yet to determine what bucket this goes in. labels Sep 21, 2022
@rokonec rokonec self-assigned this Sep 22, 2022
@AR-May AR-May self-assigned this Oct 5, 2022
@AR-May AR-May reopened this Oct 5, 2022
@AR-May
Copy link
Member

AR-May commented Oct 5, 2022

There is one more:

Unhandled exception: System.IO.IOException: Connection timed out : 'Global\msbuild-server-running-4Sfg2G4Im0xBRwnhFTml_ht8QRnhMk5UNm+og0DzA0g'
         at System.Threading.Mutex.OpenExistingWorker(String name, Mutex& result)
         at System.Threading.Mutex.TryOpenExisting(String name, Mutex& result)
         at Microsoft.Build.Execution.ServerNamedMutex.WasOpen(String mutexName)

Forgind pushed a commit that referenced this issue Oct 10, 2022
…or. (#8024)

Fixes #7993

Summary
In the MSBuild server, we identify the state of the server via mutexes. Sometimes, for reason yet unknown to us, mutex could throw the exception System.IO.IOException: Connection timed out. When this occurs, we fallback to old behavior building without server. We fixed some of those in #8000, but now found more situations when this happens.

Customer Impact
MSBuild non-Windows users could have intermittent error when building with dotnet build.
This does not affect Visual Studio.

Regression?
Yes, this is a regression.

Testing
Unit tests.

Risk
Low risk. The fix adds additional try-catch blocks to process this situation.

Code Reviewers
[TODO]

Description of the fix
Add a try-catch block to catch and process the IOException exception when mutexes are used.
Add a new client exit type for this kind of error.
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment