Resolve TypeTable race in live test RunspacePool#29250
Draft
vidai-msft wants to merge 1 commit intomainfrom
Draft
Resolve TypeTable race in live test RunspacePool#29250vidai-msft wants to merge 1 commit intomainfrom
vidai-msft wants to merge 1 commit intomainfrom
Conversation
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.
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
Contributor
There was a problem hiding this comment.
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 -AppendPathinAzError.ps1toTypesToProcessinAz.Accounts.psd1to eliminate the concurrency race - Re-enabled two
Assert-AreEqualassertions on$t.StateinFileTests.ps1that 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 |
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.
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
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.mdand reviewed the following information:ChangeLog.mdfile(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.## Upcoming Releaseheader in the past tense.ChangeLog.mdif no new release is required, such as fixing test case only.