-
Notifications
You must be signed in to change notification settings - Fork 84
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: get_children should not break supervision tree integrity #311
Conversation
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.
Let's not add a take functionality and just fix the bug in get_children
clearing the collection
ractor/src/actor/supervision.rs
Outdated
@@ -134,15 +134,21 @@ impl SupervisionTree { | |||
} | |||
} | |||
|
|||
pub(crate) fn get_children(&self) -> Vec<ActorCell> { | |||
pub(crate) fn take_children(&self) -> Vec<ActorCell> { |
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.
we shouldn't need a take method anywhere, the supervision tree should only be modified upon link/unlink. This should be as easy as just replacing the functionality inside with the non-clearing version, and updating a test case to make sure that the supervision tree isn't modified.
#310 is indeed a bug, and fixing it vs adding a new API like this is better for footgun safety.
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 think some kind of clearing is still required. Initially I just removed the clear()
but then the double-link test run out of stack. I realized if we don't clear the children list after unlink, we can run into mutual recursion in the double-link scenario. So instead of calling clear()
everywhere I created the take method.
Check out this commit. Feel free to pull it on top and update your PR |
8b061c4
to
62efc43
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.
Looks great, thanks!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #311 +/- ##
==========================================
+ Coverage 82.04% 82.07% +0.02%
==========================================
Files 61 61
Lines 12182 12183 +1
==========================================
+ Hits 9995 9999 +4
+ Misses 2187 2184 -3 ☔ View full report in Codecov by Sentry. |
This fixes #310
Please suggest where and what tests I can add.