Start heartbeatSender after Welcome, see #3388
* Otherwise, if the Welcome message is lost, other nodes in the cluster will send HeartbeatRequest and it will start sending heartbeats without being a real member and the lost Welcome is not detected by the other members in the cluster
This commit is contained in:
parent
beed693c1b
commit
ec1626b746
1 changed files with 10 additions and 5 deletions
|
|
@ -241,9 +241,6 @@ private[cluster] final class ClusterCoreDaemon(publisher: ActorRef) extends Acto
|
|||
private def clusterCore(address: Address): ActorSelection =
|
||||
context.actorSelection(RootActorPath(address) / "system" / "cluster" / "core" / "daemon")
|
||||
|
||||
context.actorOf(Props[ClusterHeartbeatSender].
|
||||
withDispatcher(UseDispatcher), name = "heartbeatSender")
|
||||
|
||||
import context.dispatcher
|
||||
|
||||
// start periodic gossip to random nodes in cluster
|
||||
|
|
@ -304,6 +301,14 @@ private[cluster] final class ClusterCoreDaemon(publisher: ActorRef) extends Acto
|
|||
}
|
||||
}
|
||||
|
||||
def becomeInitialized(): Unit = {
|
||||
// start heartbeatSender here, and not in constructor to make sure that
|
||||
// heartbeating doesn't start before Welcome is received
|
||||
context.actorOf(Props[ClusterHeartbeatSender].
|
||||
withDispatcher(UseDispatcher), name = "heartbeatSender")
|
||||
context.become(initialized)
|
||||
}
|
||||
|
||||
def initialized: Actor.Receive = {
|
||||
case msg: GossipEnvelope ⇒ receiveGossip(msg)
|
||||
case msg: GossipStatus ⇒ receiveGossipStatus(msg)
|
||||
|
|
@ -384,7 +389,7 @@ private[cluster] final class ClusterCoreDaemon(publisher: ActorRef) extends Acto
|
|||
}
|
||||
|
||||
if (address == selfAddress) {
|
||||
context.become(initialized)
|
||||
becomeInitialized()
|
||||
joining(selfUniqueAddress, cluster.selfRoles)
|
||||
} else {
|
||||
val joinDeadline = RetryUnsuccessfulJoinAfter match {
|
||||
|
|
@ -457,7 +462,7 @@ private[cluster] final class ClusterCoreDaemon(publisher: ActorRef) extends Acto
|
|||
publish(latestGossip)
|
||||
if (from != selfUniqueAddress)
|
||||
gossipTo(from, sender)
|
||||
context.become(initialized)
|
||||
becomeInitialized()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue