Skip to content

Correct peer_handler::test_process_events_multithreaded #3254

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

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

This test was added some time ago in
0c034e9, but never made any sense. PeerManager::process_events will go around its loop as many times is required to ensure we've always processed all events which were pending prior to a process_events call, so having a test that checks that we never go around more than twice is obviously broken.

And, indeed, in CI this tests fails with some regularity.

Instead, the test here is changed to ensure that we detectably go around the loop again at least once.

Fixes #2385

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.23%. Comparing base (05ed0db) to head (e34519b).
Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3254      +/-   ##
==========================================
+ Coverage   89.65%   90.23%   +0.58%     
==========================================
  Files         125      125              
  Lines      102546   105713    +3167     
  Branches   102546   105713    +3167     
==========================================
+ Hits        91936    95395    +3459     
+ Misses       7904     7727     -177     
+ Partials     2706     2591     -115     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

while start_time.elapsed() < Duration::from_millis(100) {
let val = cfg[0].chan_handler.message_fetch_counter.load(Ordering::Acquire);
assert!(val <= 2);
std::thread::yield_now(); // Winblowz seemingly doesn't ever interrupt threads?!
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this fix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, none of the threads completely busy-loop now, they all sleep which should yield++.

This test was added some time ago in
0c034e9, but never made any sense.
`PeerManager::process_events` will go around its loop as many times
is required to ensure we've always processed all events which were
pending prior to a `process_events` call, so having a test that
checks that we never go around more than twice is obviously broken.

And, indeed, in CI this tests fails with some regularity.

Instead, the test here is changed to ensure that we detectably go
around the loop again at least once.

Fixes lightningdevkit#2385
@TheBlueMatt
Copy link
Collaborator Author

Squash-pushed with only the spelling change.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

LGTM. Merging with 1 ack since it's just a test change

@valentinewallace valentinewallace merged commit b2cdc2c into lightningdevkit:main Aug 20, 2024
18 of 21 checks passed
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.

Process_events_multithreaded is flaky
2 participants