-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Remove distributed pubsub nodes on leave #20828
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
Remove distributed pubsub nodes on leave #20828
Conversation
Can one of the repo owners verify this patch? |
nodes -= m.address | ||
registry -= m.address | ||
} | ||
|
||
case MemberRemoved(m, _) if m.address == selfAddress ⇒ |
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.
the if
should be after =>
otherwise it will be "logged" as unhandled
It should also do the same thing as before on MemberRemoved
, because a member might be removed without leaving.
Another thing we should consider is if it would still be interesting to use the leaving/exiting nodes for the broadcast Publish
messages, but not for the single destination Send
messages.
True. Will elaborate on that. In the meanwhile I found a nifty quickfix. One just has to add the following actor (on each pubsub member node): final class PubSubLeftNodesCleaner extends Actor with ActorLogging {
val cluster = Cluster(context.system)
val mediator = DistributedPubSub(context.system).mediator
override def preStart() = cluster.subscribe(self, ClusterEvent.initialStateAsEvents, classOf[MemberLeft])
override def postStop() = cluster.unsubscribe(self)
override def receive = {
case MemberLeft(member) =>
// fake member removed event
mediator ! MemberRemoved(member.copy(status = Removed), member.status)
}
} |
Having this possibility one could argue, that this PR is not even needed. Although I still think, cleaning nodes on |
I think there are two reasons to also not broadcast to leaving nodes:
|
I agree, the whole point of graceful leave is that everyone is notified in advance and starts to re-route traffic before the node is fully gone, resulting in less lost messages. |
Sounds good to me |
LGTM |
OK TO TEST |
Just noticed tests didn't run yet |
Test FAILed. |
This ensures that gracefully leaving nodes (which would terminate after their own removed event) are already unregistered on all other pubsub nodes, before termination.
Ups my bad. Now test should run through |
Test PASSed. |
Thanks for contributing, @choffmeister |
This ensures that gracefully leaving nodes (which would terminate after
their own removed event) are already unregistered on all other pubsub
nodes, before termination.
See #20826