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

Using Invoke-SqlCmd in ForEach-Object -Parallel loop - not threadsafe? #69

Open
jplee75 opened this issue Dec 26, 2023 · 3 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@jplee75
Copy link

jplee75 commented Dec 26, 2023

It appears that Invoke-SqlCmd is not threadsafe - is this correct? Can it be made to be so?

Got this error while executing in a ForEach-Object -Parallel type loop

Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
##[error]PowerShell exited with code '1'.

Version Info
Name Value


PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Ubuntu 22.04.3 LTS
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Name : SqlServer
Path : /home/vsts/.local/share/powershell/Modules/SqlServer/22.1.1
/SqlServer.psd1
Version : 22.1.1

@jplee75
Copy link
Author

jplee75 commented Jan 8, 2024

I know I posted this over the end of the year - is there more information I could provide to be helpful or possible to get an answer if Invoke-SqlCmd should be safe or not to use with For-Each Object -Parallel ?

@Matteo-T
Copy link
Collaborator

Hi @jplee75 - I believe you are correct and this is a fairly old issue (it predates having this repo where we collect the issues).

For now and until I can take a look and fix it, I would recomment to stay away from it.

@ZianAtFirstWatch
Copy link

I'm able to reproduce the issue with version 22.2.0 of the SQLServer module on PowerShell version 7.4.2 and Microsoft Windows 10.0.19045.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants