-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fix hodlinvoice deadlock #8827
base: master
Are you sure you want to change the base?
fix hodlinvoice deadlock #8827
Conversation
Important Review skippedAuto reviews are limited to specific labels. Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
9904b12
to
a8c2f96
Compare
So this is still a draft and no tests added yet, tho I want your spotlight on the following topics before continuing: See also #8803 (comment) for the overall design.
I had to change the EventReceiver because I wanted to be flexible in using a particular ID for the subsriber, so I went with the short channel ID, so that when an HTLC gets resolved I can quickly look up the relevant subscriber just by using the shortchanID which is part of the HTLC (resolution) info. Another approach would be that we always register the correct subscriber to an Hodl HTLC meaning that instead of:
we would need to change the set to a map with the subscribers as a value
Then we would need to add the subscriber in the If we do it the latter way, I think there would be no need for the introduction of an interface of the EventReceiver.
|
a8c2f96
to
ccf06a1
Compare
|
||
for { | ||
select { | ||
case msg := <-h.event: |
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.
probably better to make the event an interface, with an action type function ?
Unless I'm missing something, I don't see how the introduction of the interface actually helps things here. I see no mention of the ShortChannelID in the updated Impl or in a new implementation.
This seems like the way I would try to handle it. Overall I don't know that I can endorse the HTLCNotifier interface, mostly because I don't see what it is solving. The main issue at hand here is that the invoice registry has a lot of its data structures being accessed concurrently from different threads. In other parts of LND we've started to take the approach of moving everything into the main event loop of the component. So rather than having methods on the invoice registry that directly modify data structures, locked or otherwise. Instead, we describe the actions we want to occur and then send those over some channel into the main event loop. This guarantees sequential processing of all data owned by the invoice registry which will then allow us to remove locking infrastructure which should drastically reduce the deadlock risk. |
Fixes #8803
Depends on #8826