-
-
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
Address issue 2473 #2587
Address issue 2473 #2587
Conversation
Can you please merge master? That should fix CI. |
This test demonstrates a panic that occurs when the user inserts an item with an instant in the past, and then tries to reset the timeout using the returned key
Rebased onto master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong. The DelayQueue
should not try to remove things from the wheel that are not in the wheel. It seems like a special case in reset_at
would be more appropriate, similar to what DelayQueue::remove
does:
tokio/tokio/src/time/delay_queue.rs
Lines 461 to 466 in d2f81b5
// Special case the `expired` queue | |
if self.slab[key.index].expired { | |
self.expired.remove(&key.index, &mut self.slab); | |
} else { | |
self.wheel.remove(&key.index, &mut self.slab); | |
} |
That said, I'm not sure and spent a long time staring at this trying to figure out what the variables really mean.
ah sorry, I thought it was supposed to as the doc states |
Well, the |
Which is the source of the problem causing the panic. I can move the test to reset_at if you think this is more appropriate (should work either way) |
Yeah, I think it is better to have |
Trying to remove an already expired Timer Wheel entry (called by DelayQueue.reset()) causes panics in some cases as described in (tokio-rs#2573) This prevents this panic by removing the item from the expired queue and not the wheel in these cases
Replaced the fix commit with a check in the DelayQueue |
Motivation
Resetting expired timers can cause panics (see #2473)
Solution
Add an additional check in the remove function fixes this issue.
Please feel free to discard the second commit if you think it is incorrect / correct me if I put the test in the wrong location.