-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Decrement thread count on thread exit. #1562
Conversation
I hit a problem that after 10 seconds idle, no blocking tasks would run anymore as all blocking threads exited and the Pool was convinced that there were still runners available.
It looks like I duped #1560, but that patch does not decrement the total thread count. |
I don't know what happened, but I managed to hit a decrement that underflowed num_idle to 2^32-1 with this patch applied. |
A notify at the wrong time can otherwise get us to underflow.
@carllerche Thanks for the review ! |
I just noticed another issue: |
@AnickaBurova for the case you are mentionning, if I am not mistaken, the idle count should be decremented by 1 for every wakeup signaled. Have you hit a case in practice where num_idle > num_th ? edit: Have you hit a case in practice where num_idle > num_th with this patch applied ? |
Merging master should fix the clippy failure (#1569). |
I took the liberty of merging master to get this fix in sooner 👍 |
I hit a problem that after 10 seconds idle, no blocking tasks would
run anymore as all blocking threads exited and the Pool was convinced
that there were still runners available.
Nowhere in the code is num_th decremented. Please make sure the num_idle decrement is correct at that point in the code.
Motivation
Solution