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

Fixing premature pruning of Topics #3322

Merged
merged 4 commits into from
Feb 15, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ public DistributedPubSubMediator(DistributedPubSubSettings settings)
{
if (_registry.TryGetValue(_cluster.SelfAddress, out var bucket))
{
if (bucket.Content.TryGetValue(remove.Path, out var valueHolder) && valueHolder.Ref != null)
if (bucket.Content.TryGetValue(remove.Path, out var valueHolder) && !valueHolder.Ref.IsNobody())
{
Context.Unwatch(valueHolder.Ref);
PutToRegistry(remove.Path, null);
PutToRegistry(remove.Path, ActorRefs.Nobody);
}
}
});
Expand Down Expand Up @@ -329,7 +329,7 @@ public DistributedPubSubMediator(DistributedPubSubSettings settings)

if (_registry.TryGetValue(_cluster.SelfAddress, out var bucket))
if (bucket.Content.TryGetValue(key, out var holder) && terminated.ActorRef.Equals(holder.Ref))
PutToRegistry(key, null); // remove
PutToRegistry(key, ActorRefs.Nobody); // remove
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the change


_buffer.RecreateAndForwardMessagesIfNeeded(key, () => NewTopicActor(terminated.ActorRef.Path.Name));
});
Expand Down Expand Up @@ -371,7 +371,7 @@ public DistributedPubSubMediator(DistributedPubSubSettings settings)
Receive<ClusterEvent.IMemberEvent>(_ => { /* ignore */ });
Receive<Count>(_ =>
{
var count = _registry.Sum(entry => entry.Value.Content.Count(kv => kv.Value.Ref != null));
var count = _registry.Sum(entry => entry.Value.Content.Count(kv => !kv.Value.Ref.IsNobody()));
Sender.Tell(count);
});
Receive<DeltaCount>(_ =>
Expand Down Expand Up @@ -488,7 +488,7 @@ IEnumerable<IActorRef> Refs()

if (!(allButSelf && address == _cluster.SelfAddress) && bucket.Content.TryGetValue(path, out var valueHolder))
{
if (valueHolder != null && !Equals(valueHolder.Ref, ActorRefs.Nobody))
if (valueHolder != null && !valueHolder.Ref.IsNobody())
yield return valueHolder.Ref;
}
}
Expand Down Expand Up @@ -549,7 +549,7 @@ private void HandlePrune()
var bucket = entry.Value;

var oldRemoved = bucket.Content
.Where(kv => (bucket.Version - kv.Value.Version) > _settings.RemovedTimeToLive.TotalMilliseconds)
.Where(kv => kv.Value.Ref.IsNobody() && (bucket.Version - kv.Value.Version) > _settings.RemovedTimeToLive.TotalMilliseconds)
.Select(kv => kv.Key);

if (oldRemoved.Any())
Expand Down