Avoid gossip merge when singleton cluster, see #2250

This commit is contained in:
Patrik Nordwall 2012-06-19 16:00:45 +02:00
parent 09e92b6bd9
commit dccb0ca2d7
3 changed files with 23 additions and 54 deletions

View file

@ -893,7 +893,11 @@ class Cluster(system: ExtendedActorSystem, val failureDetector: FailureDetector)
val localGossip = localState.latestGossip val localGossip = localState.latestGossip
val winningGossip = val winningGossip =
if (remoteGossip.version <> localGossip.version) { if (isSingletonCluster(localState) && localGossip.overview.unreachable.isEmpty && remoteGossip.members.contains(self)) {
// a fresh singleton cluster that is joining, no need to merge, use received gossip
remoteGossip
} else if (remoteGossip.version <> localGossip.version) {
// concurrent // concurrent
val mergedGossip = remoteGossip merge localGossip val mergedGossip = remoteGossip merge localGossip
val versionedMergedGossip = mergedGossip :+ vclockNode val versionedMergedGossip = mergedGossip :+ vclockNode

View file

@ -19,11 +19,11 @@ object SunnyWeatherMultiJvmSpec extends MultiNodeConfig {
val fourth = role("fourth") val fourth = role("fourth")
val fifth = role("fifth") val fifth = role("fifth")
// Note that this test uses default configuration,
// not MultiNodeClusterSpec.clusterConfig
commonConfig(ConfigFactory.parseString(""" commonConfig(ConfigFactory.parseString("""
akka.cluster { akka.cluster {
nr-of-deputy-nodes = 0 nr-of-deputy-nodes = 0
# FIXME remove this (use default) when ticket #2239 has been fixed
gossip-interval = 400 ms
} }
akka.loglevel = INFO akka.loglevel = INFO
""")) """))

View file

@ -118,33 +118,18 @@ abstract class TransitionSpec
awaitMembers(first, second) awaitMembers(first, second)
memberStatus(first) must be(Up) memberStatus(first) must be(Up)
memberStatus(second) must be(Joining) memberStatus(second) must be(Joining)
seenLatestGossip must be(Set(first))
cluster.convergence.isDefined must be(false) cluster.convergence.isDefined must be(false)
} }
enterBarrier("second-joined") enterBarrier("second-joined")
first gossipTo second first gossipTo second
runOn(second) {
members must be(Set(first, second))
memberStatus(first) must be(Up)
memberStatus(second) must be(Joining)
// we got a conflicting version in second, and therefore not convergence in second
seenLatestGossip must be(Set(second))
cluster.convergence.isDefined must be(false)
}
second gossipTo first second gossipTo first
runOn(first) {
seenLatestGossip must be(Set(first, second))
}
first gossipTo second
runOn(second) {
seenLatestGossip must be(Set(first, second))
}
runOn(first, second) { runOn(first, second) {
memberStatus(first) must be(Up) memberStatus(first) must be(Up)
memberStatus(second) must be(Joining) memberStatus(second) must be(Joining)
seenLatestGossip must be(Set(first, second))
cluster.convergence.isDefined must be(true) cluster.convergence.isDefined must be(true)
} }
enterBarrier("convergence-joining-2") enterBarrier("convergence-joining-2")
@ -191,42 +176,20 @@ abstract class TransitionSpec
second gossipTo first second gossipTo first
runOn(first) { runOn(first) {
members must be(Set(first, second, third)) members must be(Set(first, second, third))
cluster.convergence.isDefined must be(false)
memberStatus(third) must be(Joining) memberStatus(third) must be(Joining)
seenLatestGossip must be(Set(first, second))
cluster.convergence.isDefined must be(false)
} }
first gossipTo third first gossipTo third
runOn(third) {
members must be(Set(first, second, third))
cluster.convergence.isDefined must be(false)
memberStatus(third) must be(Joining)
// conflicting version
seenLatestGossip must be(Set(third))
}
third gossipTo first third gossipTo first
third gossipTo second third gossipTo second
runOn(first, second) {
seenLatestGossip must be(Set(myself, third))
}
first gossipTo second
runOn(second) {
seenLatestGossip must be(Set(first, second, third))
cluster.convergence.isDefined must be(true)
}
runOn(first, third) {
cluster.convergence.isDefined must be(false)
}
second gossipTo first
second gossipTo third
runOn(first, second, third) { runOn(first, second, third) {
seenLatestGossip must be(Set(first, second, third)) members must be(Set(first, second, third))
memberStatus(first) must be(Up) memberStatus(first) must be(Up)
memberStatus(second) must be(Up) memberStatus(second) must be(Up)
memberStatus(third) must be(Joining) memberStatus(third) must be(Joining)
seenLatestGossip must be(Set(first, second, third))
cluster.convergence.isDefined must be(true) cluster.convergence.isDefined must be(true)
} }
@ -283,19 +246,21 @@ abstract class TransitionSpec
"startup a second separated cluster consisting of nodes fourth and fifth" taggedAs LongRunningTest in { "startup a second separated cluster consisting of nodes fourth and fifth" taggedAs LongRunningTest in {
runOn(fourth) { runOn(fourth) {
cluster.join(fifth) cluster.join(fifth)
awaitMembers(fourth, fifth)
cluster.gossipTo(fifth)
awaitSeen(fourth, fifth)
cluster.convergence.isDefined must be(true)
} }
runOn(fifth) { runOn(fifth) {
awaitMembers(fourth, fifth) awaitMembers(fourth, fifth)
cluster.gossipTo(fourth) }
awaitSeen(fourth, fifth) testConductor.enter("fourth-joined")
cluster.gossipTo(fourth)
fifth gossipTo fourth
fourth gossipTo fifth
runOn(fourth, fifth) {
memberStatus(fourth) must be(Joining)
memberStatus(fifth) must be(Up)
seenLatestGossip must be(Set(fourth, fifth))
cluster.convergence.isDefined must be(true) cluster.convergence.isDefined must be(true)
} }
enterBarrier("fourth-joined-fifth")
enterBarrier("after-4") enterBarrier("after-4")
} }