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

Fixed deadlock in injection_queue_depth_multi_thread test #6916

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

jofas
Copy link
Contributor

@jofas jofas commented Oct 18, 2024

This closes #6847 by removing the deadlock from the test as discussed in #6876. The changes I made are based on this suggestion. I made the blocking tasks block by letting them wait on a message from a std::mpsc channel. This is quite convenient IMO, because we can exit the blocking tasks simply by dropping all Senders of the channel.1

Footnotes

  1. Unlike the previous implementation that used Barriers for synchronization—even if the test were to unforeseeably panic—the blocking tasks would still exit and cause the test to fail early instead of timing out.

if i != depth {
fail = Some(format!("{i} is not equal to {depth}"));
break;
'next_try: for _ in 0..10 {
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually do this kind of retrying by defining two functions, to separate out the concerns.

Copy link
Contributor Author

@jofas jofas Oct 20, 2024

Choose a reason for hiding this comment

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

I abstracted the act of blocking the runtime into its own fallible function. Hope this is what you meant by separating the concerns, it felt to me like it fits into the general design of Tokio's integration test suite.

@jofas jofas force-pushed the fix-flaky-injection-queue-test branch 3 times, most recently from 65ab87c to a406e7a Compare October 20, 2024 05:11
@jofas jofas force-pushed the fix-flaky-injection-queue-test branch from a406e7a to b692f53 Compare October 20, 2024 05:38
Copy link
Member

@mox692 mox692 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 doing this!

@Darksonn Darksonn merged commit ce1c74f into tokio-rs:master Oct 21, 2024
81 checks passed
@jofas jofas deleted the fix-flaky-injection-queue-test branch October 21, 2024 08:16
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

Successfully merging this pull request may close these issues.

Test injection_queue_depth_multi_thread is flaky
3 participants