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

Race condition in SmartThreadPool causes not processing tasks #26

Open
jeernest opened this issue Jan 13, 2021 · 4 comments
Open

Race condition in SmartThreadPool causes not processing tasks #26

jeernest opened this issue Jan 13, 2021 · 4 comments

Comments

@jeernest
Copy link

Hi,

I found an issue in using groups and I would like to check if it is known issue or not.

steps to reproduce:

  1. Start a ThreadPool with a WorkGroup - set MinThreads = 0, MaxThreads =1, IdleTimeout = 60 seconds
  2. Send a task to WorkItemGroup every 60 seconds
  3. after some time, tasks stop to process

Here is what happens:
Thread#1 [STP Worker thread] timeouts, because it has empty queue for 60 seconds and starts terminating (there's still some work to do after the timeout check and before the thread is freed)
In meantime
Thread#2 [new thread] enqueues a task to the WorkItemGroup,
Thread#2 WorkItemGroup enqueues a task to SmartThreadPool expecting that STP withdraw the task,
Thread#2 STP enqueues a task and doesn't start a thread, because there's one already running (it doesn't know that it's terminating)
Thread#1 [STP Worker thread] finishes termination and removes itself from STP
Thread#3 [new thread] [Receiver] enqueues a task to Work Items Group
Thread#3 WorkItemGroup doesn't do anything, because it thinks that STP has already enough tasks in queue

since then the STP has no running thread and all new tasks are enqueued to the WorkItemGroup and the queue is growing and never processed

@MichelZ
Copy link

MichelZ commented May 5, 2021

Have you found a solution for this? I think I am experiencing something similar

@jeernest
Copy link
Author

jeernest commented May 5, 2021

Unfortuntely, no. We stopped using work item groups and everything started to work.

@jirkapok
Copy link

Which versions are affected by this issue?

@jeernest
Copy link
Author

Which versions are affected by this issue?

As far as I remember it was 2.0

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

3 participants