Skip to content

Fix staged upgrade races and installer error handling#1961

Merged
tyrielv merged 1 commit into
microsoft:masterfrom
tyrielv:tyrielv/streamlined-upgrade-fixes
May 8, 2026
Merged

Fix staged upgrade races and installer error handling#1961
tyrielv merged 1 commit into
microsoft:masterfrom
tyrielv:tyrielv/streamlined-upgrade-fixes

Conversation

@tyrielv
Copy link
Copy Markdown
Contributor

@tyrielv tyrielv commented May 7, 2026

Follow-up to #1958 addressing review feedback from @KeithIsSleeping:

  1. StopService/StagingUpdateService error handling - Exec returns false only when sc.exe can't launch. Non-zero sc.exe exit codes were silently ignored. Now checks ResultCode separately and logs/raises on failure.

  2. Timer race in RequestHandler - Two concurrent unmounts on separate pipe threads could both see pendingUpgradeTimer == null and create duplicate timers. Added lock around timer create/reset.

  3. .ready marker race - Service was started via AfterInstall hook before .ready was written in ssPostInstall. If the last mount exited during install, the debounce timer would fire, skip (no .ready), and staged files would sit until next restart. Moved service start to after .ready is written.

Address review feedback from microsoft#1958:

- StopService/StagingUpdateService: check sc.exe exit code separately
  from Exec launch failure. Previously non-zero sc.exe results were
  silently ignored.

- Timer race: wrap pendingUpgradeTimer create/reset in a lock. Two
  concurrent unmounts on separate pipe threads could both observe null
  and create duplicate timers, causing parallel TryApplyPendingUpgrade.

- .ready race: move service start from AfterInstall hook to ssPostInstall
  after .ready marker is written. Previously the service could start its
  5s debounce timer before .ready existed, skip the upgrade, and leave
  staged files until the next service restart.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
@tyrielv tyrielv enabled auto-merge May 7, 2026 21:02
@tyrielv tyrielv requested a review from KeithIsSleeping May 8, 2026 20:12
@tyrielv tyrielv merged commit 8e1c9bf into microsoft:master May 8, 2026
50 checks passed
@mjcheetham mjcheetham mentioned this pull request May 11, 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.

2 participants