azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Add-AzureRmVhd sporadically fails with error "The pipeline was not run because a pipeline is already running. Pipelines cannot be run concurrently"

Open bganapa opened this issue 9 years ago • 18 comments

Cmdlet(s)

Add-AzureRmVhd

Module Version

Compute module 1.2.3.4 - azure stack version

Description

We are trying to upload the image to a storage blob. As a part of putting the image into the blob, we use Add-AzureRmVhd (https://github.com/Azure/AzureStack-Tools/blob/e73d52686d9db0f63b3560019d47cc65c77d147b/ComputeAdmin/AzureStack.ComputeAdmin.psm1#L183) This cmdlet sporadically fails with "The pipeline was not run because a pipeline is already running. Pipelines cannot be run concurrently"

The issue is also discussed here. https://social.msdn.microsoft.com/Forums/en-US/2e825e81-d00e-42ef-bec7-4a92a5565a33/can-run-addazurevhd?forum=windowsazuremanagement

I have checked the latest code with stack-dev branch code for this particular cmdlet. There are no changes addressing this issue

bganapa avatar Nov 13 '17 23:11 bganapa

@hyonholee, may I know if you had a chance to look at this issue? If not, could you let me know when we expect an update?

knithinc avatar Dec 01 '17 19:12 knithinc

I'm encountering the same issue. @hyonholee Can you maybe add a -force option so the current running pipeline can terminated and let the Add-AzureRmVhd continue?

enihcam avatar Jan 12 '18 02:01 enihcam

I'm encountering the same issue on Windows Server 1907 on Azure

wbpluto avatar Mar 12 '18 08:03 wbpluto

Same issue is still hapening for us. We have now created a do/while loop to get around this issue.

DdenBraver avatar Jul 10 '18 09:07 DdenBraver

ping @hyonholee

praries880 avatar Aug 01 '18 23:08 praries880

@praries880 Are you hitting this issue against Azure or AZURESTACK? Whats your module version of Compute

bganapa avatar Aug 01 '18 23:08 bganapa

@bganapa againt azure.

praries880 avatar Aug 02 '18 00:08 praries880

I am getting the same issue. Any update ?

gsingla294 avatar Oct 16 '18 13:10 gsingla294

@gsingla294 SAME PROBLEM. Any fixes?

barracud avatar Apr 13 '19 10:04 barracud

Thanks for reporting the issue. We will investigate it. Thanks.

hyonholee avatar Apr 23 '19 17:04 hyonholee

Tested the Add-AzVhd cmdlet with Az.Compute (4.2.1) and I wasn't able to reproduce the bug.

image

MS-syh2qs avatar Aug 13 '20 21:08 MS-syh2qs

Any stack trace anyone experiencing this can provide would help to pinpoint the cause of this issue. In Windows PowerShell 5.1 this can be obtained with $error[0] | fl * -force and possibly $error[0].Exception | fl * -force. In PowerShell 7, you can use Get-Error.

From https://github.com/PowerShell/PowerShell/issues/13497, the issue was occurring here:

https://github.com/Azure/azure-powershell/blob/1bcbe7b1f7a3323ac98f7754ba03eeb6b45e79f2/src/Compute/Compute/Models/PSSyncOutputEvents.cs#L92-L101

This was caused by trying to reuse a runspace already in use to run another PowerShell invocation. The correct solution for this depends on the requirements of the scenario, but looking at the code in that class it seems to all be UI facing, meaning an easy first iteration on a fix would be to do away with PowerShell creation and instead calling the Host UI directly:

rjmholt avatar Aug 24 '20 20:08 rjmholt

We've been running into this issue regularly. We added the exception logging code that @rjmholt suggested above, which came back with this

ErrorRecord    : The pipeline was not run because a pipeline is already running. Pipelines cannot be run concurrently.
Message        : The pipeline was not run because a pipeline is already running. Pipelines cannot be run concurrently.
Data           : {}
InnerException : 
TargetSite     : Void DoConcurrentCheck(Boolean, System.Object, Boolean)
StackTrace     :    at System.Management.Automation.Runspaces.PipelineBase.DoConcurrentCheck(Boolean syncCall, Object 
                 syncObject, Boolean isInLock)
                    at System.Management.Automation.Runspaces.RunspaceBase.DoConcurrentCheckAndAddToRunningPipelines(Pi
                 pelineBase pipeline, Boolean syncCall)
                    at System.Management.Automation.Runspaces.PipelineBase.CoreInvoke(IEnumerable input, Boolean 
                 syncCall)
                    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                    at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean 
                 performSyncInvoke)
                    at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace 
                 rsToUse, Boolean isSync)
                    at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 
                 input, PSDataCollection`1 output, PSInvocationSettings settings)
                    at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, 
                 PSDataCollection`1 output, PSInvocationSettings settings)
                    at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
                    at Microsoft.Azure.Commands.Compute.Models.PSSyncOutputEvents.LogProgressComplete(Int32 
                 activityId, String activity)
                    at Microsoft.Azure.Commands.Compute.Models.PSSyncOutputEvents.ProgressUploadComplete(TimeSpan 
                 elapsed)
                    at Microsoft.WindowsAzure.Commands.Sync.ProgressTracker.Dispose(Boolean disposing)
                    at Microsoft.WindowsAzure.Commands.Sync.ProgressTracker.Dispose()
                    at Microsoft.WindowsAzure.Commands.Sync.Upload.BlobSynchronizer.Synchronize()
                    at Microsoft.Azure.Commands.Compute.Models.VhdUploaderModel.Upload(UploadParameters 
                 uploadParameters)
                    at Microsoft.Azure.Commands.Compute.StorageServices.AddAzureVhdCommand.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
HelpLink       : 
Source         : System.Management.Automation
HResult        : -2146233079

In our case we're trying to run this as part of a CI system, and since this seems to be relating to the progress bar (which isn't even visible anywhere) we're going to see if we can set $ProgressPreference = "SilentlyContinue" to work around this for now.

MSLaguana avatar Sep 18 '20 18:09 MSLaguana

@MSLaguana Also consider adding few retries in a loop.

bganapa avatar Sep 18 '20 18:09 bganapa

For what it's worth, after we turned off progress updates we haven't seen this bite us again, so that seems like a workable mitigation until the underlying issue is fixed.

MSLaguana avatar Sep 21 '20 18:09 MSLaguana

I had the same error, is there any update on this?

SuriGangs avatar Jun 09 '23 01:06 SuriGangs

:bell: Routing this issue to @act-observability-squad.