-
Notifications
You must be signed in to change notification settings - Fork 433
Fix race condition in async UtxoFuture resolution
#4348
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: main
Are you sure you want to change the base?
Conversation
|
🎉 This PR is now ready for review! |
7c871f2 to
5c757b3
Compare
| .read_only() | ||
| .channels() | ||
| .get(&valid_announcement.contents.short_channel_id) | ||
| .unwrap() |
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.
same here. the rustfmt behavior of treating things like as_ref().unwrap() as "equally important" as ".get(X) or ".features" makes this so hard to follow.
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.
Fixed.
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.
Still the same on the latest version?
5c757b3 to
e3bf6a5
Compare
f672e27 to
7c08572
Compare
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.
Now switched to a much less invasive approach where we simply keep track of the pending future states Arcs in a separate Vec until the next call of check_resolved_futures, which will collect completed states and prune the data structures.
|
Whoops, seems there are still some more tests to fix, drafting again 🤭 |
7c08572 to
585fd56
Compare
Signed-off-by: Elias Rohrer <dev@tnull.de>
Previously, we refactored the `GossipVerifier` to not require holding a circular reference. As part of this, we moved to a model where the `UtxoFuture`s are now polled by the background processor which checks for completion through `get_and_clear_pending_msg_events`. However, as part of this refactor we introduced race-condition: as we only held `Weak` references in `PendingChecksContext` and the `UtxoFuture` was directly dropped by the `GossipVerifier` after calling `resolve`, the actual data was dropped with the future and gone when the background processor attempted to retrieve and apply it via `check_resolved_futures`. Here, we fix this issue by simply holding on to the `state` `Arc`s in a separate `pending_states` `Vec` that is only pruned in `check_resolved_futures`, ensuring any completed results are collected first. Signed-off-by: Elias Rohrer <dev@tnull.de>
585fd56 to
0da4883
Compare
... and they're passing again. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4348 +/- ##
==========================================
+ Coverage 86.08% 86.11% +0.02%
==========================================
Files 156 156
Lines 102428 102625 +197
Branches 102428 102625 +197
==========================================
+ Hits 88179 88377 +198
- Misses 11754 11755 +1
+ Partials 2495 2493 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
TheBlueMatt
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.
Bleh, don't love the extra vec but you're right that its much simpler and probably worth it. Feel free to squash (maybe with a few more rustfmt'isms fixed) and let's land this.
| .read_only() | ||
| .nodes() | ||
| .get(&node_id_1) | ||
| .unwrap() |
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.
These are also pretty borderline (there's a few more further down).
| .read_only() | ||
| .channels() | ||
| .get(&valid_announcement.contents.short_channel_id) | ||
| .unwrap() |
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.
Still the same on the latest version?
|
👋 The first review has been submitted! Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer. |
Fixes #4346.
Previously, we refactored the
GossipVerifierto not require holding acircular reference. As part of this, we moved to a model where the
UtxoFutures are now polled by the background processor which checksfor completion through
get_and_clear_pending_msg_events.However, as part of this refactor we introduced race-condition: as we
only held
Weakreferences inPendingChecksContextand theUtxoFuturewas directly dropped by theGossipVerifierafter callingresolve, the actual data was dropped with the future and gone when thebackground processor attempted to retrieve and apply it via
check_resolved_futures.Here, we fix this issue by simply holding on to the
stateArcs in aseparate
pending_statesVecthat is only pruned incheck_resolved_futures, ensuring any completed results are collectedfirst.