-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[BUG] pendingTimeouts may be incorrect in the HashedWheelTimer #3173
Comments
Hi. We may not be talking about the same situation. What I encountered was: A |
This appears to be a bug in the HashedWheelTimer implementation where canceled timeouts can cause incorrect pendingTimeouts counts, potentially leading to negative values. Root Cause 1.Multiple timeouts are scheduled for the same tick 2.These timeouts get transferred to their target bucket 3.They are canceled before the wheel actually processes that bucket 4.The pendingTimeouts counter is decremented for each cancellation, but wasn't properly accounted for in this state Impact 2.Resource Control Bypass: If maxPendingTimeouts is set, this bug could allow exceeding the intended limit Suggested Fixes
}
|
Hi @harshita2626, Thank you for your reply. In my opinion, the root cause of this bug is that the method is not cohesive enough and the responsibility is not single enough. Consider the following code.
For this, I have fixed and created a pr #3174 . |
okay !good to know that.Thank you for sharing your insightful analysis
|
Is there an existing issue for this?
Current Behavior
If a
Timeout
inHashedWheelTimer
has been transferred to a bucket and is canceled before it is actually expired in the goal tick,pendingTimeouts
may be repeatedly decremented.If the user sets a positive
maxPendingTimeouts,
this bug means that the maximum number of tasks can be potentially increased.Expected Behavior
The
pendingTimeouts
inHashedWheelTimer
can correctly reflect the number of waiting tasks.Steps To Reproduce
The following test code reproduces the bug.
Got the following test failures and ended up with a negative
pendingTimeouts
.Environment
Debug logs
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: