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

Resolve some deadlocks #2373

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

A9G-Data-Droid
Copy link
Contributor

@A9G-Data-Droid A9G-Data-Droid commented May 14, 2024

I know that you said you are scared of changes to the core of Quartz and for good reason. I am new here and I don't understand this code base. I want to submit my suggestions here but I'm not going to claim this is correct. There are always many ways to solve problems.

My goals here are to attempt to resolve #2354 by implementing the two core tenants of async:

  1. Do not synchronously block waiting in an async method.
  2. Do not call asynchronous code from sync methods.

I have attempted to clarify the pause mechanism by implementing a clearly named async pause token. I replaced some old locks with new SemaphoreSlim, which allows async wait. There is a concern that SemaphoreSlim does not maintain the order of those awaiting.

I have tested this in my own solution and "it works on my machine". It also appears to pass unit tests. So while it's functional, it may have another set of edge cases.

I tried to maintain the existing structure and avoid breaking changes.

 - Do not sync wait on ValueTask, always call ToTask first.
 - Safe cleanup actions.
 - ContinueWith on TaskScheduler.Default instead of current
 - Attempt to bypass with Task.Run until Shutdown can be made async
 - Ingest AsyncManualResetEvent, PauseTokenSource and adapt them
 - Implement pauseToken in the QuartzSchedulerThread
 - Replace `lock` with `SemaphoreSlim` for async awaiting
 - Replace `SignalTaskComplete` with an explicit task
 - Task Start should happen in the lock with AddCount
Copy link

sonarcloud bot commented May 14, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@A9G-Data-Droid
Copy link
Contributor Author

Spoke too soon. The result of that test here suggests it is still deadlocking.

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