You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by bd...@apache.org on 2026/10/22 18:08:14 UTC
(cassandra) 02/02: ninja: fix startup with MT disabled
This is an automated email from the ASF dual-hosted git repository.
bdeggleston pushed a commit to branch cep-45-mutation-tracking
in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 9ad6d9b5e0988e20f18a58bef38103cefee86187
Author: Blake Eggleston <bl...@ultrablake.com>
AuthorDate: Thu Oct 22 09:21:51 2026 -0700
ninja: fix startup with MT disabled
---
.../org/apache/cassandra/db/SystemKeyspace.java | 60 +++++++++++-----------
.../db/compaction/TrackedCompactionManager.java | 2 +-
.../tracking/MutationTrackingFeatureFlagTest.java | 24 +++++----
3 files changed, 45 insertions(+), 41 deletions(-)
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index 44573d0696..c9ef1d812b 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -652,37 +652,35 @@ public final class SystemKeyspace
private static Tables tables()
{
- Tables.Builder builder = Tables.builder().add(BuiltIndexes,
- Batches,
- Paxos,
- PaxosRepairHistoryTable,
- Local,
- PeersV2,
- LegacyPeers,
- PeerEventsV2,
- LegacyPeerEvents,
- CompactionHistory,
- LegacySSTableActivity,
- SSTableActivity,
- LegacySizeEstimates,
- TableEstimates,
- AvailableRangesV2,
- LegacyAvailableRanges,
- TransferredRangesV2,
- LegacyTransferredRanges,
- ViewBuildsInProgress,
- BuiltViews,
- PreparedStatements,
- Repairs,
- TopPartitions,
- LocalMetadataLog,
- Snapshots,
- ConsensusMigrationState);
-
- if (DatabaseDescriptor.getMutationTrackingEnabled())
- builder.add(HostLogId, Shards, CoordinatorLogs);
-
- return builder.build();
+ return Tables.builder().add(BuiltIndexes,
+ Batches,
+ Paxos,
+ PaxosRepairHistoryTable,
+ Local,
+ PeersV2,
+ LegacyPeers,
+ PeerEventsV2,
+ LegacyPeerEvents,
+ CompactionHistory,
+ LegacySSTableActivity,
+ SSTableActivity,
+ LegacySizeEstimates,
+ TableEstimates,
+ AvailableRangesV2,
+ LegacyAvailableRanges,
+ TransferredRangesV2,
+ LegacyTransferredRanges,
+ ViewBuildsInProgress,
+ BuiltViews,
+ PreparedStatements,
+ Repairs,
+ TopPartitions,
+ LocalMetadataLog,
+ Snapshots,
+ ConsensusMigrationState,
+ HostLogId,
+ Shards,
+ CoordinatorLogs).build();
}
private static volatile Map<TableId, Pair<CommitLogPosition, Long>> truncationRecords;
diff --git a/src/java/org/apache/cassandra/db/compaction/TrackedCompactionManager.java b/src/java/org/apache/cassandra/db/compaction/TrackedCompactionManager.java
index 2f7746fb52..5db43619b7 100644
--- a/src/java/org/apache/cassandra/db/compaction/TrackedCompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/TrackedCompactionManager.java
@@ -424,7 +424,7 @@ public class TrackedCompactionManager extends AbstractStrategyHolder
@VisibleForTesting
boolean isPromotable(SSTableReader sstable)
{
- if (!MutationTrackingService.instance().isStarted())
+ if (!MutationTrackingService.isEnabled() || !MutationTrackingService.instance().isStarted())
return false;
if (sstable.isRepaired() || sstable.isPendingRepair())
diff --git a/test/distributed/org/apache/cassandra/distributed/test/tracking/MutationTrackingFeatureFlagTest.java b/test/distributed/org/apache/cassandra/distributed/test/tracking/MutationTrackingFeatureFlagTest.java
index bfc6bd9ab6..b219ac8bde 100644
--- a/test/distributed/org/apache/cassandra/distributed/test/tracking/MutationTrackingFeatureFlagTest.java
+++ b/test/distributed/org/apache/cassandra/distributed/test/tracking/MutationTrackingFeatureFlagTest.java
@@ -35,6 +35,7 @@ import org.apache.cassandra.db.virtual.MutationTrackingTables;
import org.apache.cassandra.db.virtual.SystemViewsKeyspace;
import org.apache.cassandra.db.virtual.VirtualTable;
import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.ConsistencyLevel;
import org.apache.cassandra.distributed.api.Feature;
import org.apache.cassandra.distributed.api.IInvokableInstance;
import org.apache.cassandra.distributed.api.IIsolatedExecutor;
@@ -49,7 +50,7 @@ import static org.apache.cassandra.distributed.api.Feature.NETWORK;
import static org.apache.cassandra.replication.MutationTrackingService.DISABLED_MESSAGE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
public class MutationTrackingFeatureFlagTest extends TestBaseImpl
{
@@ -72,10 +73,10 @@ public class MutationTrackingFeatureFlagTest extends TestBaseImpl
.has(AssertionUtils.isThrowableInstanceof(InvalidRequestException.class))
.hasMessage(DISABLED_MESSAGE);
- // Mutation tracking system keyspace tables should not be present:
- assertNull(cluster.get(1).callOnInstance(() -> Schema.instance.getTableMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.HOST_LOG_ID)));
- assertNull(cluster.get(1).callOnInstance(() -> Schema.instance.getTableMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.SHARDS)));
- assertNull(cluster.get(1).callOnInstance(() -> Schema.instance.getTableMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.COORDINATOR_LOGS)));
+ // Mutation tracking system keyspace tables always exist, so commit log replay works if the flag is toggled:
+ assertNotNull(cluster.get(1).callOnInstance(() -> Schema.instance.getTableMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.HOST_LOG_ID)));
+ assertNotNull(cluster.get(1).callOnInstance(() -> Schema.instance.getTableMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.SHARDS)));
+ assertNotNull(cluster.get(1).callOnInstance(() -> Schema.instance.getTableMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.COORDINATOR_LOGS)));
// Make sure virtual tables don't exist:
IIsolatedExecutor.SerializableCallable<Stream<VirtualTable>> hasMutationTrackingTables =
@@ -91,7 +92,7 @@ public class MutationTrackingFeatureFlagTest extends TestBaseImpl
}
@Test
- public void shouldFailOnBounceWhenDisabledAfterEnabled() throws Exception
+ public void shouldStartOnBounceWhenDisabledAfterEnabled() throws Exception
{
try (Cluster cluster = builder().withNodes(1)
.withConfig(c -> c.with(Feature.NETWORK).set("mutation_tracking.enabled", true))
@@ -101,15 +102,20 @@ public class MutationTrackingFeatureFlagTest extends TestBaseImpl
cluster.schemaChange(withKeyspace("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1} AND replication_type='tracked'"));
cluster.schemaChange(withKeyspace("CREATE TABLE %s.tbl (k int primary key, v int)"));
+ cluster.coordinator(1).execute(withKeyspace("INSERT INTO %s.tbl (k, v) VALUES (1, 1)"), ConsistencyLevel.ALL);
+ cluster.get(1).flush(KEYSPACE);
+
IInvokableInstance bouncingNode = cluster.get(1);
bouncingNode.shutdown().get();
bouncingNode.config().set("mutation_tracking.enabled", false);
Config badConfig = YamlConfigurationLoader.fromMap(bouncingNode.config().getParams(), true, Config.class);
Config.setOverrideLoadConfig(() -> badConfig);
- Assertions.assertThatThrownBy(() -> bouncingNode.startup(cluster))
- .has(AssertionUtils.isThrowableInstanceof(IllegalStateException.class))
- .hasMessage(DISABLED_MESSAGE);
+ bouncingNode.startup(cluster);
+
+ // Flushed data written while tracking was enabled stays on disk. Unflushed data lives in the journal, which is not replayed while disabled.
+ Object[][] rows = bouncingNode.executeInternal(withKeyspace("SELECT k, v FROM %s.tbl WHERE k = 1"));
+ assertEquals(1, rows.length);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org