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

Make -Force parameter in Stop-RSJob permanent so it "just works" #43

Closed
proxb opened this issue Sep 24, 2015 · 9 comments
Closed

Make -Force parameter in Stop-RSJob permanent so it "just works" #43

proxb opened this issue Sep 24, 2015 · 9 comments
Assignees

Comments

@proxb
Copy link
Owner

proxb commented Sep 24, 2015

Stop-RSJob should "just work" without the need of the -Force parameter so it doesn't hang on waiting for a job to finish. Fix already completed and just needs uploaded tonight.

@proxb proxb self-assigned this Sep 24, 2015
@proxb proxb closed this as completed Sep 24, 2015
@mkruchten
Copy link

Was this ever implemented or was it subsequently removed? I'm trying to use Stop-RSJob to stop hung WMI calls in my scriptblock, and the call to Stop-RSJob is just hanging as well. This is on 1.7.3.9, and I'm also not seeing a -Force parameter in the function.

@MVKozlov
Copy link
Contributor

please show output of Stop-RSJob with -Verbose -Debug switches

@mkruchten
Copy link

That produced the following, which doesn't appear to be much help. It doesn't do anything beyond that, it's hung up at this point.

DEBUG: Begin
DEBUG: Process
DEBUG: End
DEBUG: ParameterSet: Job
VERBOSE: Stopping f4a82347-835f-439d-9eaf-cef6882c6ca4
VERBOSE: Killing job f4a82347-835f-439d-9eaf-cef6882c6ca4

@MVKozlov
Copy link
Contributor

MVKozlov commented May 17, 2017

Do you tried to use the latest from GitHub ?
I'm asking because I do not see all the messages from current build

Maybe the fix already here or maybe the hang occurs inside the powershell itself (or WMI) and we can't help you a lot

@mkruchten
Copy link

I'm using 1.7.3.9 which I believe is the latest version. I looked at the code for stop-rsjob and those are the only messages I see, it appears that it's hanging on [void] $_.InnerJob.Stop(). I know it's a WMI call that's causing it to hang, but I should still be able to kill that thread similar to other scripts where we're using the native Stop-Job commands. There's a lot of overhead using Powershell jobs, so I've been working on converting to using PoshRSJob instead.

@MVKozlov
Copy link
Contributor

MVKozlov commented May 17, 2017

The latest here is 1.7.3.11, it not marked as release but have important fix which can be decisive in your case.
The hang can occur if $_.InnerJob.Stop() throws exception and [System.Threading.Monitor]::Exit($PoshRS_jobs.syncroot) not executed - its a deadlock.

Similar deadlocks was eliminated in some other places inside module.

@mkruchten
Copy link

I downloaded and tested 1.7.3.11 and it hangs up on the same statement. I don't know what it is about WMI that causes this, I've tried various techniques to prevent this and still run into server that cause the WMI call to just hang indefinitely. Killing the thread seems to be the only option left.

@MVKozlov
Copy link
Contributor

what so special about these WMI calls ?
Can I reproduce it on my environment ?
may be the WMI on these servers should be repaired ?

@mkruchten
Copy link

Nothing special about the WMI call, just gathering drive space information using Win32_Volume. It's not clear exactly what's wrong with WMI that's causing this, as most of the time if WMI needs to be fixed the call fails. We've also tried multiple ways to get the WMI call to timeout as well, but still occasionally run into servers where the WMI call will hang indefinitely and cause Powershell to hang.

As I mentioned we have a workaround using Powershell jobs to run against servers in parallel, since we can successfully kill the job for an individual server. I thought that Stop-RSJob would work the same way and kill that runspace, but it just hangs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants