-
Notifications
You must be signed in to change notification settings - Fork 44
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
System.Threading.SynchronizationLockException #31
Comments
I think that the lock is done and the next call, the exception is thrown (see LocalLock source code) ;
|
facing the same issue. things worked fine for almost a month, then all of a sudden this error in my logs and the process no longer executing as scheduled. |
Has there been a resolution found for this issue? I'm seeing the same error as @ghabre, using the same attributes, but I am a bit behind on Nuget updates (1.6.0 instead of 1.6.3). |
hi @avlcodemonkey, the way i solved it was a bit hacky and manual.. whevener i start execution of the scheduled event, i also started in parallel a task.Delay for 2 hours (figured my task should never exceed that) and then whenever any of the two tasks completed i cancelled and disposed the other one. below some code snippet hope it helps:
|
Thanks for the info @ghabre. I was considering an approach using It originally appeared to me that there was a lock issue preventing a job from being performed, even when there were no other instances running. I set up a test with job I think the original issue I saw may not have been the caused by |
Same issue.
How to solve? |
As possible fix added one more recurring job to check the status of other recurring jobs + with the ability to call this method through the api.
And to simulate the occurrence of a situation in which the job is not executed added the following code to one of the jobs:
|
Hi 2019, 2021 here just checking if there is an update on this for an actual fix. |
Running into the same issue :( Monitor.TryEnter(); throws the exception, after "Dispose()" was called on another thread for the same lock. Probably Monitor.Exit() is called on the "foreign" thread, throws an exception and the lock objects is never removed from the "Locks" ConcurrentDictionary, however the exception is probably caught. We should either use a SemaphoreSlim instead of a "lock" object + monitor or we should just remove the lock object form the Locks Dictionary if Monitor.Exit() throws an exception. The more i think about this piece of code the more i see problem b.t.w. just imagine the following case: In summary: The lock object should not be removed from the Locks Dictionary if someone is still using it, this process itself (checking / acquiring) needs to be synchronized as well. I will do a merge request this weekend, when i have free time to do it. Another Option would be to juse use Hangfire.InMemory instead of Hangfire.MemoryStorage which is the memory storage implementation from the hangfire team |
Thank you about the explanation of the issue and your MR proposal |
Any update on this one, please? :) Also how can we force this exception to happen? |
@perrich @Spacefish Do you have some updates on that? It is a very critial issue. |
As you can see, no PR was provided but some workarounds have been explained. |
@mentapro no i use the NuGet Package Hangfire.MemoryStorage, which is the semi "official" MemoryStorage implementation from the hangfire devs, which does not have this problem. |
Any updates on this? |
Ok damn it, i will fix it, even if i don´t use the library any more. Getting notifications for that thread since over a year now. |
I did a PR here: #41 |
I added a UnitTest for this as well in #42 |
Hi i get the following error when using the MemoryStorage:
The job that is causing this error has the following attributes
[AutomaticRetry(Attempts = 0)][DisableConcurrentExecution(timeoutInSeconds: 60)]
What could be causing this issue?
The text was updated successfully, but these errors were encountered: