This is an automated email from the ASF dual-hosted git repository. samt pushed a commit to branch cep-21-tcm in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 09a9e089bf7881f9faf75d48fdf7b48736a17fae Author: Alex Petrov <[email protected]> AuthorDate: Thu Dec 15 17:19:21 2022 +0100 [CEP-21] Improve seedlist inspection at startup patch by Sam Tunnicliffe; reviewed by Alex Petrov and Marcus Eriksson for CASSANDRA-18404 --- src/java/org/apache/cassandra/tcm/Discovery.java | 2 +- src/java/org/apache/cassandra/tcm/Startup.java | 33 +++++++++++++----------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/java/org/apache/cassandra/tcm/Discovery.java b/src/java/org/apache/cassandra/tcm/Discovery.java index 9320e9bffb..a353828121 100644 --- a/src/java/org/apache/cassandra/tcm/Discovery.java +++ b/src/java/org/apache/cassandra/tcm/Discovery.java @@ -75,7 +75,7 @@ public class Discovery DiscoveredNodes last = null; int lastCount = discovered.size(); int unchangedFor = 0; - while (Clock.Global.nanoTime() <= deadline && unchangedFor < rounds) + while (Clock.Global.nanoTime() <= deadline || unchangedFor < rounds) { last = discoverOnce(null); if (last.kind == DiscoveredNodes.Kind.CMS_ONLY) diff --git a/src/java/org/apache/cassandra/tcm/Startup.java b/src/java/org/apache/cassandra/tcm/Startup.java index f5b93d2619..a49a3d088e 100644 --- a/src/java/org/apache/cassandra/tcm/Startup.java +++ b/src/java/org/apache/cassandra/tcm/Startup.java @@ -212,18 +212,21 @@ package org.apache.cassandra.tcm; if (seeds.isEmpty()) throw new IllegalArgumentException("Can not initialize CMS without any seeds"); - boolean hasFirstEpoch = SystemKeyspaceStorage.hasFirstEpoch(); - boolean isOnlySeed = DatabaseDescriptor.getSeeds().size() == 1 && DatabaseDescriptor.getSeeds().contains(FBUtilities.getBroadcastAddressAndPort()); - boolean hasBootedBefore = SystemKeyspace.getLocalHostId() != null; - logger.info("hasFirstEpoch = {}, hasBootedBefore = {}", hasFirstEpoch, hasBootedBefore); - if (!hasFirstEpoch && hasBootedBefore) - return UPGRADE; - else if (hasFirstEpoch) - return NORMAL; - else if (isOnlySeed) - return FIRST_CMS; - else - return VOTE; - } - } - } + boolean hasFirstEpoch = SystemKeyspaceStorage.hasFirstEpoch(); + // For CCM and local dev clusters + boolean isOnlySeed = DatabaseDescriptor.getSeeds().size() == 1 + && DatabaseDescriptor.getSeeds().contains(FBUtilities.getBroadcastAddressAndPort()) + && DatabaseDescriptor.getSeeds().iterator().next().getAddress().isLoopbackAddress(); + boolean hasBootedBefore = SystemKeyspace.getLocalHostId() != null; + logger.info("hasFirstEpoch = {}, hasBootedBefore = {}", hasFirstEpoch, hasBootedBefore); + if (!hasFirstEpoch && hasBootedBefore) + return UPGRADE; + else if (hasFirstEpoch) + return NORMAL; + else if (isOnlySeed) + return FIRST_CMS; + else + return VOTE; + } + } +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
