Closed Mitrug closed 1 week ago
I discussed this behaviour with @cloudmark and concluded that, while it is true we are not waiting for the child actors to terminate before swapping the parent's mailbox, the end result remains the same. In both cases, the parent actor still cannot process any new messages produced by the child, and those messages ultimately end up in the dead letter queue.
Issue Description
When a PoisonPill is sent to a parent actor, it is expected that the child actor will terminate first, followed by the parent. However, in certain cases, the example below demonstrates that this termination order is not consistently followed, resulting in the parent sometimes terminating before the child. This issue appears intermittently, suggesting a possible race condition or timing inconsistency in the shutdown sequence.
Reproduction Example
The following test case aims to verify that the child actor stops before the parent when a PoisonPill is sent to the parent. However, the test periodically fails, with the child actor terminating after the parent.
The output of the above test case when the Parent dies first:
The DeathWatchNotification originating from the Child Actor would be transferred to the DeadLetter Mailbox since the parent mailbox would already be closed.