-
Notifications
You must be signed in to change notification settings - Fork 2.2k
netann: fix race condition in TestChanStatusManagerStateMachine #10437
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
base: master
Are you sure you want to change the base?
netann: fix race condition in TestChanStatusManagerStateMachine #10437
Conversation
Fix a race condition in the "add new channels" subtest where the manager's status sampling ticker could fire between adding channel edge policies and marking channels as active in the switch. This race caused the manager to: 1. Discover new channels with enabled edge policies 2. Check if they're active (they weren't yet) 3. Schedule and send a disable update The fix reorders the operations to mark channels active before adding edge policies, ensuring the manager always sees them as active.
Summary of ChangesHello @ellemouton, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a race condition identified in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request fixes a race condition in the TestChanStatusManagerStateMachine's "add new channels" subtest. The change correctly reorders operations by marking new channels as active before adding their edge policies to the graph. This prevents a scenario where the manager's ticker could find a new, enabled channel that is not yet active, leading to an incorrect disable update. The fix is logical, well-explained in the updated comment, and should resolve the test flakiness.
|
the itest flake cannot possibly be linked to this diff since this only touches unit test code |
yyforyongyu
left a comment
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.
Thanks a lot for taking a look!!
So the flake comes from this line,
lnd/netann/chan_status_manager.go
Lines 536 to 537 in 3d7ff86
| if m.cfg.IsChannelActive(chanID) { | |
| continue |
which requires the channel to be found here,
lnd/netann/chan_status_manager_test.go
Line 333 in 3d7ff86
| IsChannelActive: htlcSwitch.HasActiveLink, |
which checks the map here,
lnd/netann/chan_status_manager_test.go
Line 299 in 3d7ff86
| active, ok := s.isActive[chanID] |
which is added here via
markActive,lnd/netann/chan_status_manager_test.go
Line 394 in 3d7ff86
| h.htlcSwitch.SetStatus(chanID, true) |
Now when the ticker fires, inside markPendingInactiveChannels, it gets a list of channels to look at from,
lnd/netann/chan_status_manager.go
Line 508 in 3d7ff86
| channels, err := m.fetchChannels() |
which is the
g.chans() here,lnd/netann/chan_status_manager_test.go
Line 160 in 3d7ff86
| return g.chans(), nil |
which is added here in the test,
lnd/netann/chan_status_manager_test.go
Lines 742 to 744 in 3d7ff86
| for _, c := range newChans { | |
| h.graph.addChannel(c) | |
| } |
So I think to completely fix the flake, we need to call h.markActive before the above loop where we call h.graph.addChannel?
|
@ziggie1984: review reminder |
Fix a race condition in the "add new channels" subtest where the manager's status sampling ticker could fire between adding channel edge policies and marking channels as active in the switch.
This race caused the manager to:
The fix reorders the operations to mark channels active before adding edge policies, ensuring the manager always sees them as active.
FIxes a flake found in this build