Skip to content

Resolve TypeTable race in live test RunspacePool#29250

Draft
vidai-msft wants to merge 1 commit intomainfrom
vidai/livetest-job-issue
Draft

Resolve TypeTable race in live test RunspacePool#29250
vidai-msft wants to merge 1 commit intomainfrom
vidai/livetest-job-issue

Conversation

@vidai-msft
Copy link
Contributor

Move type loading from Update-TypeData -AppendPath in AzError.ps1 to TypesToProcess in Az.Accounts.psd1. The -AppendPath path triggers ProcessTypeFiles() which performs a non-atomic Read-Clear-Rebuild on the shared RunspacePool TypeTable, corrupting engine ETS types (e.g. Job.State) when multiple workers concurrently import Az.Accounts.

TypesToProcess is loaded via Import-Module Bind(updateOnly=true) which never calls TypeTable.Clear(), eliminating the race. This is the idiomatic PowerShell pattern, consistent with Az.Sql and Az.Functions.

Also re-enables the Assert-AreEqual on Job.State in FileTests.ps1 that was commented out as a workaround.

Description

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Move type loading from Update-TypeData -AppendPath in AzError.ps1 to
TypesToProcess in Az.Accounts.psd1. The -AppendPath path triggers
ProcessTypeFiles() which performs a non-atomic Read-Clear-Rebuild on
the shared RunspacePool TypeTable, corrupting engine ETS types (e.g.
Job.State) when multiple workers concurrently import Az.Accounts.

TypesToProcess is loaded via Import-Module Bind(updateOnly=true) which
never calls TypeTable.Clear(), eliminating the race. This is the
idiomatic PowerShell pattern, consistent with Az.Sql and Az.Functions.

Also re-enables the Assert-AreEqual on Job.State in FileTests.ps1
that was commented out as a workaround.
Copilot AI review requested due to automatic review settings March 10, 2026 02:14
@azure-client-tools-bot-prd
Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Contributor

Copilot AI left a comment

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 fixes a race condition in the PowerShell RunspacePool's shared TypeTable that occurs when multiple workers concurrently import Az.Accounts. The root cause was Update-TypeData -AppendPath in AzError.ps1, which performs a non-atomic Read-Clear-Rebuild on the TypeTable. The fix moves type loading to the idiomatic TypesToProcess manifest entry in Az.Accounts.psd1, consistent with how Az.Sql and Az.Functions handle their type data.

Changes:

  • Moved type loading from Update-TypeData -AppendPath in AzError.ps1 to TypesToProcess in Az.Accounts.psd1 to eliminate the concurrency race
  • Re-enabled two Assert-AreEqual assertions on $t.State in FileTests.ps1 that were previously commented out as a workaround for the race condition

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Accounts/Accounts/Az.Accounts.psd1 Added TypesToProcess = 'Accounts.types.ps1xml' to module manifest for safe, idiomatic type loading
src/Accounts/Accounts/StartupScripts/AzError.ps1 Removed the Update-TypeData -AppendPath call that caused the TypeTable race condition
src/Storage/LiveTests/Storage.Management/FileTests.ps1 Re-enabled two Assert-AreEqual "Completed" $t.State checks that were commented out as a workaround

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