-
Notifications
You must be signed in to change notification settings - Fork 412
Cleanup lock orders #1773
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
Cleanup lock orders #1773
Conversation
@@ -681,23 +674,25 @@ pub type SimpleRefChannelManager<'a, 'b, 'c, 'd, 'e, M, T, F, L> = ChannelManage | |||
// | | |||
// |__`forward_htlcs` | |||
// | | |||
// |__`channel_state` | |||
// |__`pending_background_events` |
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.
I'd just like to ask if process_background_events
through timer_tick_occurred
can be called by a thread while another thread has other locks acquired? If so, I'll drop the second commit that moves this.
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.
I've realized in hindsight that this question is rather stupid, as "background threads" acquiring pending_background_events
is fine even if other threads are holding other locks at the same time. We just need to ensure that every single thread acquires the locks according to the lock order in that specific thread only to avoid deadlocks.
Codecov ReportBase: 90.79% // Head: 90.76% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1773 +/- ##
==========================================
- Coverage 90.79% 90.76% -0.04%
==========================================
Files 87 87
Lines 46969 46979 +10
Branches 46969 46979 +10
==========================================
- Hits 42646 42640 -6
- Misses 4323 4339 +16
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
As the `channel_state` lock will be removed, this PR prepare for that by flipping the lock order for `pending_inbound_payments` and `pending_outbound_payments` locks to before the `channel_state` lock.
c3de918
to
a9f3e45
Compare
Closing this due to most of this already having been addressed through #1772. |
This is based on #1772, so it can be marked as blocked on dependent pr for now. Will also leave it as draft until #1772 is merged.
The first commit moves the lock_order of
pending_inbound_payments
as well aspending_outbound_payments
to before thechannel_state
lock, which is to be removed. This will simplify #1507.The second commit
pending_background_events
into a separate lock order branch.