installer: wait on _MSIExecute mutex instead of failing on 1618#9
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves MSI installation robustness by serializing msiexec launches behind the global Global\_MSIExecute mutex and treating 1618 (ERROR_INSTALL_ALREADY_RUNNING) as a scheduling collision rather than a package failure, preventing retry budget exhaustion during concurrent installs (e.g., ESP/Intune).
Changes:
- Added
WaitForWindowsInstallerIdle()helper that pollsGlobal\_MSIExecutebefore launchingmsiexec. - Updated MSI retry loop to wait/retry on
1618without consuming the per-package retry budget, with a collision cap. - Adjusted logging and retry behavior to preserve existing handling for non-
1618failures.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1250
to
+1254
| // Serialize behind any in-progress MSI transaction so we don't collide | ||
| // with 1618 ERROR_INSTALL_ALREADY_RUNNING in the first place. This is | ||
| // the "brute force" part: BootstrapMate waits its turn instead of failing. | ||
| WaitForWindowsInstallerIdle(installerIdleWaitSeconds); | ||
|
|
Comment on lines
1255
to
+1257
| using var process = Process.Start(startInfo); | ||
| if (process != null) | ||
| if (process == null) continue; | ||
|
|
Comment on lines
+1284
to
+1287
| WriteLog($"MSI already running (1618) - waiting for the active installer to finish, then retrying (collision {collisions}, not counted as a failed attempt)"); | ||
| WaitForWindowsInstallerIdle(installerIdleWaitSeconds); | ||
| attempt--; // do not count a scheduling collision against maxRetries | ||
| continue; |
…off on 1618 (review)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
During ESP, the Intune Management Extension and BootstrapMate both drive msiexec concurrently, so installs collide with 1618 ERROR_INSTALL_ALREADY_RUNNING. The old loop counted 1618 against the per-package retry budget and surfaced a [!] warning, so a long concurrent install could exhaust retries and fail a good package.
Fix
Genuine failures (non-zero, non-1618) keep existing retry/fail behavior — this does not swallow real install errors.
Test
dotnet build BootstrapMate.csproj -c Release succeeds (0 errors).