You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2025/12/03 13:28:53 UTC

(cassandra) branch trunk updated (0212713750 -> b5f8ac2604)

This is an automated email from the ASF dual-hosted git repository.

marcuse pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


    from 0212713750 Fix flaky test CompressionDictionarySchedulerTest.testScheduleSSTableBasedTrainingWithSSTables
     new 7802743460 Fix issue when running cms reconfiguration with paxos repair disabled
     new b5f8ac2604 Update system schema tables with new distributed keyspace on upgrade

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.txt                                        |  2 ++
 .../apache/cassandra/schema/DistributedSchema.java | 21 ++++++++++++++++----
 .../cassandra/service/ActiveRepairService.java     |  6 ++----
 src/java/org/apache/cassandra/tcm/Startup.java     | 23 +++++++++++++++++++++-
 .../cassandra/tcm/sequences/ReconfigureCMS.java    | 11 ++++++-----
 .../distributed/test/log/ReconfigureCMSTest.java   | 13 ++++++++++++
 .../upgrade/ClusterMetadataUpgradeTest.java        |  6 ++++++
 7 files changed, 68 insertions(+), 14 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


(cassandra) 01/02: Fix issue when running cms reconfiguration with paxos repair disabled

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

marcuse pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 780274346018cf1c66dd1d1bdba0a227700d8cf4
Author: Marcus Eriksson <ma...@apache.org>
AuthorDate: Thu Aug 28 11:00:17 2025 +0200

    Fix issue when running cms reconfiguration with paxos repair disabled
    
    Patch by marcuse; reviewed by Sam Tunnicliffe for CASSANDRA-20869
---
 CHANGES.txt                                                 |  1 +
 .../org/apache/cassandra/service/ActiveRepairService.java   |  6 ++----
 .../org/apache/cassandra/tcm/sequences/ReconfigureCMS.java  | 11 ++++++-----
 .../cassandra/distributed/test/log/ReconfigureCMSTest.java  | 13 +++++++++++++
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 1e9bbaa2fe..b3dbba2f9b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 5.1
+ * Fix issue when running cms reconfiguration with paxos repair disabled (CASSANDRA-20869)
  * Added additional parameter to JVM shutdown to allow for logs to be properly shutdown (CASSANDRA-20978)
  * Improve isGossipOnlyMember and location lookup performance (CASSANDRA-21039)
  * Refactor the way we check if a transformation is allowed to be committed during upgrades (CASSANDRA-21043)
diff --git a/src/java/org/apache/cassandra/service/ActiveRepairService.java b/src/java/org/apache/cassandra/service/ActiveRepairService.java
index a6641eccd5..5d2a8c89c4 100644
--- a/src/java/org/apache/cassandra/service/ActiveRepairService.java
+++ b/src/java/org/apache/cassandra/service/ActiveRepairService.java
@@ -20,7 +20,6 @@ package org.apache.cassandra.service;
 import java.io.IOException;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -118,7 +117,6 @@ import org.apache.cassandra.utils.TimeUUID;
 import org.apache.cassandra.utils.concurrent.AsyncPromise;
 import org.apache.cassandra.utils.concurrent.Future;
 import org.apache.cassandra.utils.concurrent.FutureCombiner;
-import org.apache.cassandra.utils.concurrent.ImmediateFuture;
 
 import static com.google.common.collect.Iterables.concat;
 import static com.google.common.collect.Iterables.transform;
@@ -1190,13 +1188,13 @@ public class ActiveRepairService implements IEndpointStateChangeSubscriber, IFai
         if (!paxosRepairEnabled())
         {
             logger.warn("Not running paxos repair for topology change because paxos repair has been disabled");
-            return Arrays.asList(() -> ImmediateFuture.success(null));
+            return Collections.emptyList();
         }
 
         if (ranges.isEmpty())
         {
             logger.warn("Not running paxos repair for topology change because there are no ranges to repair");
-            return Arrays.asList(() -> ImmediateFuture.success(null));
+            return Collections.emptyList();
         }
         ClusterMetadata metadata = ClusterMetadata.current();
         List<TableMetadata> tables = Lists.newArrayList(metadata.schema.getKeyspaces().getNullable(ksName).tables);
diff --git a/src/java/org/apache/cassandra/tcm/sequences/ReconfigureCMS.java b/src/java/org/apache/cassandra/tcm/sequences/ReconfigureCMS.java
index fe1ec17f3d..c0efee0ae4 100644
--- a/src/java/org/apache/cassandra/tcm/sequences/ReconfigureCMS.java
+++ b/src/java/org/apache/cassandra/tcm/sequences/ReconfigureCMS.java
@@ -30,6 +30,7 @@ import java.util.concurrent.ExecutionException;
 import java.util.function.Supplier;
 
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -198,7 +199,7 @@ public class ReconfigureCMS extends MultiStepOperation<AdvanceCMSReconfiguration
         {
             String message = "Some data streaming failed. Use nodetool to check CMS reconfiguration state and resume. " +
                              "For more, see `nodetool help cms reconfigure`.";
-            logger.warn(message);
+            logger.warn(message, t);
             return SequenceState.error(new RuntimeException(message));
         }
     }
@@ -344,10 +345,10 @@ public class ReconfigureCMS extends MultiStepOperation<AdvanceCMSReconfiguration
         // overlapping quorums invariant holds.
 
         Retry retry = Retry.withNoTimeLimit(TCMMetrics.instance.repairPaxosTopologyRetries);
-        List<Supplier<Future<?>>> remaining = ActiveRepairService.instance()
-                                                                 .repairPaxosForTopologyChangeAsync(SchemaConstants.METADATA_KEYSPACE_NAME,
-                                                                                                    Collections.singletonList(entireRange),
-                                                                                                    "CMS reconfiguration");
+        List<Supplier<Future<?>>> remaining = Lists.newArrayList(ActiveRepairService.instance()
+                                                                                    .repairPaxosForTopologyChangeAsync(SchemaConstants.METADATA_KEYSPACE_NAME,
+                                                                                                                       Collections.singletonList(entireRange),
+                                                                                                                       "CMS reconfiguration"));
 
         while (true)
         {
diff --git a/test/distributed/org/apache/cassandra/distributed/test/log/ReconfigureCMSTest.java b/test/distributed/org/apache/cassandra/distributed/test/log/ReconfigureCMSTest.java
index d0e1f358fb..ff1b7d50ac 100644
--- a/test/distributed/org/apache/cassandra/distributed/test/log/ReconfigureCMSTest.java
+++ b/test/distributed/org/apache/cassandra/distributed/test/log/ReconfigureCMSTest.java
@@ -308,6 +308,19 @@ public class ReconfigureCMSTest extends FuzzTestBase
         }
     }
 
+    @Test
+    public void testReconfigurePaxosRepairDisabled() throws IOException
+    {
+        try (Cluster cluster = builder().withNodes(3)
+                                        .withConfig(c -> c.with(Feature.NETWORK)
+                                                          .set("paxos_repair_enabled", "false"))
+                                        .withoutVNodes()
+                                        .start())
+        {
+            cluster.get(1).nodetoolResult("cms", "reconfigure", "3").asserts().success();
+        }
+    }
+
     private PaxosRepairHistory paxosRepairHistory(IInvokableInstance instance)
     {
         Object[][] rows = instance.executeInternal("select points from system.paxos_repair_history " +


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


(cassandra) 02/02: Update system schema tables with new distributed keyspace on upgrade

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

marcuse pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit b5f8ac26040966750e7cacec80dd0e4dd8bfbde6
Author: Marcus Eriksson <ma...@apache.org>
AuthorDate: Fri Aug 29 08:56:34 2025 +0200

    Update system schema tables with new distributed keyspace on upgrade
    
    Patch by marcuse; reviewed by Sam Tunnicliffe for CASSANDRA-20872
---
 CHANGES.txt                                        |  1 +
 .../apache/cassandra/schema/DistributedSchema.java | 21 ++++++++++++++++----
 src/java/org/apache/cassandra/tcm/Startup.java     | 23 +++++++++++++++++++++-
 .../upgrade/ClusterMetadataUpgradeTest.java        |  6 ++++++
 4 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index b3dbba2f9b..ef556fc92d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 5.1
+ * Update system schema tables with new distributed keyspace on upgrade (CASSANDRA-20872)
  * Fix issue when running cms reconfiguration with paxos repair disabled (CASSANDRA-20869)
  * Added additional parameter to JVM shutdown to allow for logs to be properly shutdown (CASSANDRA-20978)
  * Improve isGossipOnlyMember and location lookup performance (CASSANDRA-21039)
diff --git a/src/java/org/apache/cassandra/schema/DistributedSchema.java b/src/java/org/apache/cassandra/schema/DistributedSchema.java
index 77fec54eda..1266d9b4c3 100644
--- a/src/java/org/apache/cassandra/schema/DistributedSchema.java
+++ b/src/java/org/apache/cassandra/schema/DistributedSchema.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.schema;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableList;
 import org.apache.cassandra.auth.AuthKeyspace;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql3.functions.UserFunction;
@@ -35,6 +36,7 @@ import org.apache.cassandra.tcm.serialization.MetadataSerializer;
 import org.apache.cassandra.tcm.serialization.Version;
 import org.apache.cassandra.tracing.TraceKeyspace;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.Pair;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -152,14 +154,25 @@ public class DistributedSchema implements MetadataValue<DistributedSchema>
         return keyspaces.stream().anyMatch(ksm -> ksm.tables.stream().anyMatch(TableMetadata::requiresAccordSupport));
     }
 
+    /**
+     * @deprecated since TCM, used on upgrade from gossip to populate system schema tables with the correct generation
+     */
+    @Deprecated(since = "TCM")
+    public static List<Pair<KeyspaceMetadata, Long>> distributedKeyspacesWithGeneration(Set<String> knownDatacenters)
+    {
+        return ImmutableList.of(Pair.create(DistributedMetadataLogKeyspace.initialMetadata(knownDatacenters), DistributedMetadataLogKeyspace.GENERATION),
+                                Pair.create(TraceKeyspace.metadata(), TraceKeyspace.GENERATION),
+                                Pair.create(SystemDistributedKeyspace.metadata(), SystemDistributedKeyspace.GENERATION),
+                                Pair.create(AuthKeyspace.metadata(),AuthKeyspace.GENERATION));
+    }
+
     public static DistributedSchema fromSystemTables(Keyspaces keyspaces, Set<String> knownDatacenters)
     {
         if (!keyspaces.containsKeyspace(SchemaConstants.METADATA_KEYSPACE_NAME))
         {
-            Keyspaces kss = Keyspaces.of(DistributedMetadataLogKeyspace.initialMetadata(knownDatacenters),
-                                         TraceKeyspace.metadata(),
-                                         SystemDistributedKeyspace.metadata(),
-                                         AuthKeyspace.metadata());
+            Keyspaces kss = Keyspaces.none();
+            for (Pair<KeyspaceMetadata, Long> ksmGen : distributedKeyspacesWithGeneration(knownDatacenters))
+                kss = kss.with(ksmGen.left);
             for (KeyspaceMetadata ksm : keyspaces) // on disk keyspaces
                 kss = kss.withAddedOrUpdated(kss.get(ksm.name)
                                                 .map(k -> merged(ksm, k))
diff --git a/src/java/org/apache/cassandra/tcm/Startup.java b/src/java/org/apache/cassandra/tcm/Startup.java
index 446c52a02e..53a0f6095a 100644
--- a/src/java/org/apache/cassandra/tcm/Startup.java
+++ b/src/java/org/apache/cassandra/tcm/Startup.java
@@ -18,8 +18,10 @@
 package org.apache.cassandra.tcm;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
@@ -37,6 +39,7 @@ import org.slf4j.LoggerFactory;
 import org.apache.cassandra.config.CassandraRelevantProperties;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.db.Mutation;
 import org.apache.cassandra.db.SystemKeyspace;
 import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.dht.BootStrapper;
@@ -49,8 +52,11 @@ import org.apache.cassandra.gms.NewGossiper;
 import org.apache.cassandra.gms.VersionedValue;
 import org.apache.cassandra.locator.InetAddressAndPort;
 import org.apache.cassandra.net.MessagingService;
+import org.apache.cassandra.schema.DistributedSchema;
 import org.apache.cassandra.schema.KeyspaceMetadata;
+import org.apache.cassandra.schema.Keyspaces;
 import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.schema.SchemaKeyspace;
 import org.apache.cassandra.schema.TableMetadata;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.tcm.log.LocalLog;
@@ -69,6 +75,7 @@ import org.apache.cassandra.tcm.transformations.PrepareReplace;
 import org.apache.cassandra.tcm.transformations.UnsafeJoin;
 import org.apache.cassandra.tcm.transformations.cms.Initialize;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.Pair;
 
 import static org.apache.cassandra.tcm.ClusterMetadataService.State.LOCAL;
 import static org.apache.cassandra.tcm.compatibility.GossipHelper.emptyWithSchemaFromSystemTables;
@@ -254,12 +261,26 @@ import static org.apache.cassandra.utils.FBUtilities.getBroadcastAddressAndPort;
         Election.instance.migrated();
     }
 
+    private static void updateSystemSchemaTables(Set<String> knownDatacenters)
+    {
+        List<Pair<KeyspaceMetadata, Long>> kss = DistributedSchema.distributedKeyspacesWithGeneration(knownDatacenters);
+        List<Mutation> mutations = new ArrayList<>();
+        for (Pair<KeyspaceMetadata, Long> ksm : kss)
+        {
+            Keyspaces.KeyspacesDiff ksDiff = Keyspaces.diff(Keyspaces.none(), Keyspaces.of(ksm.left));
+            mutations.addAll(SchemaKeyspace.convertSchemaDiffToMutations(ksDiff, ksm.right));
+        }
+        SchemaKeyspace.applyChanges(mutations);
+    }
+
     /**
      * This should only be called during startup.
      */
     public static void initializeFromGossip(Function<Processor, Processor> wrapProcessor, Runnable initMessaging) throws StartupException
     {
-        ClusterMetadata emptyFromSystemTables = emptyWithSchemaFromSystemTables(SystemKeyspace.allKnownDatacenters());
+        Set<String> knownDcs = SystemKeyspace.allKnownDatacenters();
+        updateSystemSchemaTables(knownDcs);
+        ClusterMetadata emptyFromSystemTables = emptyWithSchemaFromSystemTables(knownDcs);
         LocalLog.LogSpec logSpec = LocalLog.logSpec()
                                            .withInitialState(emptyFromSystemTables)
                                            .afterReplay(Startup::scrubDataDirectories,
diff --git a/test/distributed/org/apache/cassandra/distributed/upgrade/ClusterMetadataUpgradeTest.java b/test/distributed/org/apache/cassandra/distributed/upgrade/ClusterMetadataUpgradeTest.java
index eb717602f3..c7e33b8228 100644
--- a/test/distributed/org/apache/cassandra/distributed/upgrade/ClusterMetadataUpgradeTest.java
+++ b/test/distributed/org/apache/cassandra/distributed/upgrade/ClusterMetadataUpgradeTest.java
@@ -35,6 +35,7 @@ import org.apache.cassandra.tcm.membership.Location;
 import org.apache.cassandra.tcm.membership.NodeAddresses;
 import org.apache.cassandra.tcm.membership.NodeId;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.psjava.util.AssertStatus.assertTrue;
 
@@ -54,6 +55,11 @@ public class ClusterMetadataUpgradeTest extends UpgradeTestBase
             cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
         })
         .runAfterClusterUpgrade((cluster) -> {
+            Object [][] r = cluster.get(1).executeInternal("select keyspace_name from system_schema.keyspaces where keyspace_name='system_cluster_metadata'");
+            assertEquals(1, r.length);
+            r = cluster.get(1).executeInternal("select table_name from system_schema.tables where keyspace_name='system_cluster_metadata' and table_name='distributed_metadata_log'");
+            assertEquals(1, r.length);
+
             cluster.get(1).nodetoolResult("cms","initialize").asserts().success();
             cluster.forEach(i ->
             {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org