This is an automated email from the ASF dual-hosted git repository. benedict pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit ae673a31cc32a1ea3d397723c0dd893218cec5ea Author: Alex Petrov <[email protected]> AuthorDate: Mon Aug 18 09:35:50 2025 +0200 Startup sequence improvements follow-up Patch by Alex Petrov; reviewed by Benedict Elliott Smith for CASSANDRA-20822 --- .../DecayingEstimatedHistogramReservoir.java | 3 ++ .../service/accord/AccordConfigurationService.java | 10 +++-- .../cassandra/service/accord/AccordService.java | 48 +++++++++++----------- .../simulator/paxos/AccordSimulationRunner.java | 1 - 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java b/src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java index b6f2bde23a..23a06fc253 100644 --- a/src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java +++ b/src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java @@ -586,6 +586,9 @@ public class DecayingEstimatedHistogramReservoir implements CassandraReservoir sum += bCount * bucketOffsets[i]; } + if (elements == 0) + return 0d; + return (double) sum / elements; } diff --git a/src/java/org/apache/cassandra/service/accord/AccordConfigurationService.java b/src/java/org/apache/cassandra/service/accord/AccordConfigurationService.java index 0e09cd2234..0049e715bf 100644 --- a/src/java/org/apache/cassandra/service/accord/AccordConfigurationService.java +++ b/src/java/org/apache/cassandra/service/accord/AccordConfigurationService.java @@ -232,8 +232,6 @@ public class AccordConfigurationService extends AbstractConfigurationService<Acc void reportMetadataInternal(ClusterMetadata metadata) { Topology topology = AccordTopology.createAccordTopology(metadata); - if (topology.isEmpty() && isEmpty()) - return; updateMapping(metadata); if (Invariants.isParanoid()) @@ -499,7 +497,9 @@ public class AccordConfigurationService extends AbstractConfigurationService<Acc if (epoch < minEpoch() || epochs.wasTruncated(epoch)) return; - syncPropagator.reportClosed(epoch, mapping.nodes(), ranges); + Topology topology = getTopologyForEpoch(epoch); + if (topology != null) + syncPropagator.reportClosed(epoch, topology.nodes(), ranges); } @VisibleForTesting @@ -516,7 +516,9 @@ public class AccordConfigurationService extends AbstractConfigurationService<Acc checkStarted(); // TODO (expected): ensure we aren't fetching a truncated epoch; otherwise this should be non-null - syncPropagator.reportRetired(epoch, mapping.nodes(), ranges); + Topology topology = getTopologyForEpoch(epoch); + if (topology != null) + syncPropagator.reportRetired(epoch, topology.nodes(), ranges); } @Override diff --git a/src/java/org/apache/cassandra/service/accord/AccordService.java b/src/java/org/apache/cassandra/service/accord/AccordService.java index 55e90976fb..f65d3616e4 100644 --- a/src/java/org/apache/cassandra/service/accord/AccordService.java +++ b/src/java/org/apache/cassandra/service/accord/AccordService.java @@ -298,10 +298,6 @@ public class AccordService implements IAccordService, Shutdownable AccordService as = new AccordService(AccordTopology.tcmIdToAccord(tcmId)); as.startup(); - instance = as; - - AccordReplicaMetrics.touch(); - replayJournal(as); as.finishInitialization(); @@ -320,6 +316,8 @@ public class AccordService implements IAccordService, Shutdownable as.configService.registerListener(as.node.durability()); as.node.durability().start(); + instance = as; + AccordReplicaMetrics.touch(); WatermarkCollector.fetchAndReportWatermarksAsync(as.configService); return as; } @@ -456,6 +454,27 @@ public class AccordService implements IAccordService, Shutdownable // Replay local epochs for (ImmutableTopoloyImage image : images) configService.reportTopology(image.global); + + // Subscribe to TCM events + ChangeListener prevListener = MetadataChangeListener.instance.collector.getAndSet(new ChangeListener() + { + @Override + public void notifyPostCommit(ClusterMetadata prev, ClusterMetadata next, boolean fromSnapshot) + { + if (state != State.SHUTDOWN) + configService.maybeReportMetadata(next); + } + }); + + Invariants.require((prevListener instanceof MetadataChangeListener.PreInitStateCollector), + "Listener should have been initialized with Accord pre-init state collector, but was " + prevListener.getClass()); + + MetadataChangeListener.PreInitStateCollector preinit = (MetadataChangeListener.PreInitStateCollector) prevListener; + for (ClusterMetadata item : preinit.getItems()) + { + if (item.epoch.getEpoch() > Epoch.FIRST.getEpoch()) + configService.maybeReportMetadata(item); + } } /** @@ -476,27 +495,6 @@ public class AccordService implements IAccordService, Shutdownable if (remote != null) remote.forEach(configService::reportTopology, highestKnown + 1, Integer.MAX_VALUE); - - // Subscribe to TCM events - ChangeListener prevListener = MetadataChangeListener.instance.collector.getAndSet(new ChangeListener() - { - @Override - public void notifyPostCommit(ClusterMetadata prev, ClusterMetadata next, boolean fromSnapshot) - { - if (state != State.SHUTDOWN) - configService.maybeReportMetadata(next); - } - }); - - Invariants.require((prevListener instanceof MetadataChangeListener.PreInitStateCollector), - "Listener should have been initialized with Accord pre-init state collector, but was " + prevListener.getClass()); - - MetadataChangeListener.PreInitStateCollector preinit = (MetadataChangeListener.PreInitStateCollector) prevListener; - for (ClusterMetadata item : preinit.getItems()) - { - if (item.epoch.getEpoch() > minEpoch()) - configService.maybeReportMetadata(item); - } } catch (InterruptedException e) { diff --git a/test/simulator/main/org/apache/cassandra/simulator/paxos/AccordSimulationRunner.java b/test/simulator/main/org/apache/cassandra/simulator/paxos/AccordSimulationRunner.java index b2417c7f20..b8502a1147 100644 --- a/test/simulator/main/org/apache/cassandra/simulator/paxos/AccordSimulationRunner.java +++ b/test/simulator/main/org/apache/cassandra/simulator/paxos/AccordSimulationRunner.java @@ -47,7 +47,6 @@ public class AccordSimulationRunner extends SimulationRunner @BeforeClass public static void beforeAll() { - CassandraRelevantProperties.JUNIT_STORAGE_COMPATIBILITY_MODE.setString(StorageCompatibilityMode.NONE.toString()); DatabaseDescriptor.clientInitialization(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
