test(redundancy): lock in stale-Terminated guard + clarify OnTerminated (code-review)
This commit is contained in:
@@ -108,12 +108,15 @@ public sealed class PeerProbeSupervisor : ReceiveActor
|
||||
/// <param name="t">The termination notice for the dead child.</param>
|
||||
private void OnTerminated(Terminated t)
|
||||
{
|
||||
var dead = _children.FirstOrDefault(kvp => kvp.Value.Equals(t.ActorRef));
|
||||
if (!dead.Equals(default(KeyValuePair<NodeId, IActorRef>)) && dead.Value is not null)
|
||||
{
|
||||
_children.Remove(dead.Key);
|
||||
_log.Debug("PeerProbeSupervisor: pruned terminated child for peer {Peer}", dead.Key);
|
||||
}
|
||||
var entry = _children.FirstOrDefault(kvp => kvp.Value.Equals(t.ActorRef));
|
||||
// No-match yields Value == null because IActorRef is a reference type. A null here means the
|
||||
// terminated ref isn't our CURRENT child for any peer — either it was already pruned in
|
||||
// OnSnapshot (deliberate stop pre-removes from _children), or it's a stale old-generation
|
||||
// child whose peer has since been re-spawned with a fresh child. Either way: no-op, so we
|
||||
// never evict the fresh same-peer child on a stale Terminated.
|
||||
if (entry.Value is null) return;
|
||||
_children.Remove(entry.Key);
|
||||
_log.Debug("PeerProbeSupervisor: pruned terminated child for peer {Peer}", entry.Key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user