Skip to content
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

post_stop of children are being called when supervisor fails. #226

Closed
gusinacio opened this issue Apr 12, 2024 · 1 comment · Fixed by #230 or graphprotocol/indexer-rs#187
Closed
Assignees
Labels
bug Something isn't working

Comments

@gusinacio
Copy link

Describe the bug
Imagine a supervision tree with A -> B. If A panics its post_stop is not called as expected but ractor terminates all its children via normal stop with reason "Killed" and then post_stop is called for this situation.

The problem is that there's no way to identify on B's post_stop that it's being terminated because its supervisor was killed.

The documentation clearly says about post_stop:

Invoked after an actor has been stopped to perform final cleanup. In the event the actor is terminated with Signal::Kill or has self-> panicked, post_stop won't be called.
Panics in post_stop follow the supervision strategy.

For me, the actor should not trigger post_stop because it's a killed event or post_stop should have a parameter to identify the reason.

To Reproduce
Steps to reproduce the behavior:

  1. Spawn an Actor A with post_stop
  2. Spawn linked Actor B with post_stop
  3. Send a message to actor A that panics/return an error.
  4. See the post_stop from B being called.

Expected behavior
When Actor A panics, it should not trigger post_stop of Actor B.

Additional context
Ractor Version: 0.9.7
Rust Version: 1.76.0

@gusinacio gusinacio added the bug Something isn't working label Apr 12, 2024
@slawlor
Copy link
Owner

slawlor commented Apr 27, 2024

Yes this shouldn't happen, I'll investigate and work on a fix. Thank you for reporting!

@slawlor slawlor self-assigned this Apr 30, 2024
slawlor added a commit that referenced this issue Apr 30, 2024
…er to track

1. if the actor should exit the loop iteration
2. If it's going to exit, is it because it was killed?
3. The optional "exit reason"

This allows us to bypass the `post_stop` routine on killed actor shutdown.

Resolves #226
slawlor added a commit that referenced this issue Apr 30, 2024
…er to track

1. if the actor should exit the loop iteration
2. If it's going to exit, is it because it was killed?
3. The optional "exit reason"

This allows us to bypass the `post_stop` routine on killed actor shutdown.

Resolves #226
slawlor added a commit that referenced this issue Apr 30, 2024
* Add test to demonstrate the post-stop on supervisor panic problem.

* Adds a new tracking struct to the actor's main processing loop in order to track

1. if the actor should exit the loop iteration
2. If it's going to exit, is it because it was killed?
3. The optional "exit reason"

This allows us to bypass the `post_stop` routine on killed actor shutdown.

Resolves #226
aasseman added a commit to graphprotocol/indexer-rs that referenced this issue May 23, 2024
We need this fix: slawlor/ractor#226

Signed-off-by: Alexis Asseman <alexis@semiotic.ai>
aasseman added a commit to graphprotocol/indexer-rs that referenced this issue May 23, 2024
We need this fix: slawlor/ractor#226

Signed-off-by: Alexis Asseman <alexis@semiotic.ai>
aasseman added a commit to graphprotocol/indexer-rs that referenced this issue May 23, 2024
We need this fix: slawlor/ractor#226

Signed-off-by: Alexis Asseman <alexis@semiotic.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants