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

RsJob hangs and cannot be killed/removed even with -Force #213

Open
hdsouza opened this issue Feb 15, 2021 · 5 comments
Open

RsJob hangs and cannot be killed/removed even with -Force #213

hdsouza opened this issue Feb 15, 2021 · 5 comments

Comments

@hdsouza
Copy link

hdsouza commented Feb 15, 2021

Do you want to request a feature or report a bug?
Bug. Need the -force parameter to kill or delete or remove a hung job. Or any other parameter of combination of parameters and commands that will do the same.

What is the current behavior?
RsJob hangs and cannot be killed/removed even with -Force. Its been quite frequent. I am testing with 10 threads at a time and a total of 20 accounts to be processed. Since Morning I have encountered one job hanging in 3 different attempts.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
Please see attached screenshots

What is the expected behavior?
Hangs and cannot be killed

Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts?
Powershell Version = 5.1.14393.3866
Windows server 2016, OS Build 14393

Please provide a code example showing the issue, if applicable:
Instaed of the full code, I have provided just the relevant lines.

$ScriptLocal = 
{
param(
	 $Alias,
	 $Cred_Cloud
	 )
Connect-ExchangeOnline -Credential $Cred_Cloud | Out-Null 
Get-MailboxStatistics $Alias
Get-PSSession | Remove-PSSession
}

Start-RsJob -Name "job_$Alias" -ScriptBlock $ScriptLocal -ArgumentList $Alias, $Cred_Cloud
$Job | receive-rsjob | select DisplayName, LastUserActionTime

HungJob
HungJob_2

@MVKozlov
Copy link
Contributor

Are you sure your problem isn't with the Exchange cmdlets? Are they thread safe?

Can you demonstrate the same problem with simple commands?

If not, I'm pretty sure it's not RSJob's fault.

@hdsouza
Copy link
Author

hdsouza commented Feb 16, 2021

Thanks @MVKozlov . When a thread hangs, I am running 10 threads with a total of 20 jobs. That means 19 jobs are successful. That would mean that the script is fine. Also all the block is doing is "get-mailboxstatistics". This is the same script block for all threads.

I am not concerned with a hanging job as I mentioned in the initial issue. Hanging Job is not the question here. All I am saying is that the -Force switch does not work. When executed it hangs the main session as well. Doing additional searches, it appears it was reported in an earlier issue as well in a different scenario: #43 . I really like PoshRsJobs and I hope the -force parameter can be made to work correctly.

@MVKozlov
Copy link
Contributor

19 successful jobs ... It could also mean that race conditions inside cmdlets just haven't been encountered 19 times :)

The -Force switch actually does the same thing as the Stop-RSJob, so if one works, the other should work too. And vice versa.

Try using my fork as I made quite a few changes there and this project is actually frozen.

@hdsouza
Copy link
Author

hdsouza commented Feb 16, 2021

Thanks @MVKozlov . Are you saying I use the zip file from fork https://github.com/MVKozlov/PoshRSJob .
Also when I added the Wait-RSJob, I get an error 'Wait-RSJob : A parameter cannot be found that matches parameter name 'PerJobTimeout''
The command is:
Start-RsJob -Name "job_$Alias" -ScriptBlock $ScriptLocal -ArgumentList $Alias, $Cred_Cloud | Wait-RSJob -Timeout 200 -PerJobTimeout

Is the "PerJobTimeout" fixed in your fork as well?

@MVKozlov
Copy link
Contributor

MVKozlov commented Feb 16, 2021

-PerJobTimeout is the my fork feature. The original doesn't have it
If you get this error the wrong module version loaded
is Get-Module PoshRSJob return Version 1.7.5.2 ?
btw, latest not tagged version have some more fixes

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

No branches or pull requests

2 participants