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

[#5536] tokio-util: fix panic in DelayQueue #5630

Merged
merged 4 commits into from
Apr 17, 2023

Conversation

isabelleatkins
Copy link
Contributor

@isabelleatkins isabelleatkins commented Apr 17, 2023

Fixes: #5536

Motivation

Experienced an upstream service which had been running for over 2 years to have an outage due to this bug.
This was also a bug in tokio up to and including version 0.3.4.

Solution

I copied the fix in tokio, which fudges any items which have timers which would logically go into the top+1 level into the top level.

This means that you can insert an item into "the past" (if the time since the queue has been alive is in the top most level, and the item has been fudged into the top level too, and occupies an earlier slot). We handle this by bumping up the corresponding timer by the level range.

  • Added test to check that inserting to a delayqueue that has existed for more than the 2^36 ms doesn't panic.

  • Cargo fmt ran.

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR.

tokio-util/CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Darksonn Darksonn enabled auto-merge (squash) April 17, 2023 20:47
@Darksonn Darksonn merged commit 9f9e596 into tokio-rs:master Apr 17, 2023
@isabelleatkins
Copy link
Contributor Author

Hi @Darksonn - do you have an ETA for the next tokio-util release?

@Darksonn
Copy link
Contributor

If you submit a release PR for tokio-util, then I can make a release today. (Example in #5442.) Otherwise, I can make a release early next week.

@isabelleatkins
Copy link
Contributor Author

I won't have space to make that PR, but a release early next week would be great- thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-util Area: The tokio-util crate M-time Module: tokio/time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tokio-util DelayQueue wheel panics if it exists for more than 2^36 milliseconds
3 participants