This is an automated email from the ASF dual-hosted git repository.
bereng pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 70389abcf7 Bti shouldn't be available in compatibility mode
70389abcf7 is described below
commit 70389abcf78d913ea77b81cf226b10439f8db385
Author: Bereng <[email protected]>
AuthorDate: Tue Jun 6 12:37:56 2023 +0200
Bti shouldn't be available in compatibility mode
Patch by Berenguer Blasi; reviewed by Andrés de la Peña for CASSANDRA-18569
---
.../cassandra/config/DatabaseDescriptor.java | 2 +
.../cassandra/utils/StorageCompatibilityMode.java | 15 +++++-
.../utils/StorageCompatibilityModeTest.java | 57 ++++++++++++++++++++++
3 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index 4171bc4887..843511f3b0 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -1424,6 +1424,8 @@ public class DatabaseDescriptor
if (selectedFormat == null)
throw new ConfigurationException(String.format("Selected sstable
format '%s' is not available.", selectedFormatName));
+ getStorageCompatibilityMode().validateSstableFormat(selectedFormat);
+
return selectedFormat;
}
diff --git a/src/java/org/apache/cassandra/utils/StorageCompatibilityMode.java
b/src/java/org/apache/cassandra/utils/StorageCompatibilityMode.java
index 60dcc55b3f..2969597c23 100644
--- a/src/java/org/apache/cassandra/utils/StorageCompatibilityMode.java
+++ b/src/java/org/apache/cassandra/utils/StorageCompatibilityMode.java
@@ -19,6 +19,9 @@
package org.apache.cassandra.utils;
import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.io.sstable.format.SSTableFormat;
+import org.apache.cassandra.io.sstable.format.bti.BtiFormat;
/**
* The mode of compatibility with older Cassandra versions.
@@ -33,7 +36,7 @@ public enum StorageCompatibilityMode
CASSANDRA_4(4),
/**
- * Use the storage formats of the current version, but dissabling features
that are not compatible with any
+ * Use the storage formats of the current version, but disabling features
that are not compatible with any
* not-upgraded nodes in the cluster. Use this during rolling upgrades to
a new major Cassandra version. Once all
* nodes have been upgraded, you can set the compatibility to {@link
#NONE}.
*/
@@ -42,7 +45,7 @@ public enum StorageCompatibilityMode
/**
* Don't try to be compatible with older versions. Data will be written
with the most recent format, which might
* prevent a rollback to previous Cassandra versions. Features that are
not compatible with older nodes will be
- * enabled, asuming that all nodes in the cluster are in the same major
version as this node.
+ * enabled, assuming that all nodes in the cluster are in the same major
version as this node.
*/
NONE(Integer.MAX_VALUE);
@@ -67,4 +70,12 @@ public enum StorageCompatibilityMode
{
return this.major < major;
}
+
+ public void validateSstableFormat(SSTableFormat<?, ?> selectedFormat)
+ {
+ if (selectedFormat.name().equals(BtiFormat.NAME) && this ==
StorageCompatibilityMode.CASSANDRA_4)
+ throw new ConfigurationException(String.format("Selected sstable
format '%s' is not available when in storage compatibility mode '%s'.",
+
selectedFormat.name(),
+ this));
+ }
}
diff --git
a/test/unit/org/apache/cassandra/utils/StorageCompatibilityModeTest.java
b/test/unit/org/apache/cassandra/utils/StorageCompatibilityModeTest.java
new file mode 100644
index 0000000000..f8684edd62
--- /dev/null
+++ b/test/unit/org/apache/cassandra/utils/StorageCompatibilityModeTest.java
@@ -0,0 +1,57 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.cassandra.utils;
+
+import org.junit.Test;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.io.sstable.format.SSTableFormat;
+import org.apache.cassandra.io.sstable.format.big.BigFormat;
+import org.apache.cassandra.io.sstable.format.bti.BtiFormat;
+import org.assertj.core.api.Assertions;
+
+public class StorageCompatibilityModeTest
+{
+ @Test
+ public void testBtiFormatAndStorageCompatibilityMode()
+ {
+ SSTableFormat<?, ?> big = new BigFormat(null);
+ SSTableFormat<?, ?> trie = new BtiFormat(null);
+
+ for (StorageCompatibilityMode mode : StorageCompatibilityMode.values())
+ {
+ switch (mode)
+ {
+ case UPGRADING:
+ case NONE:
+ mode.validateSstableFormat(big);
+ mode.validateSstableFormat(trie);
+ break;
+ case CASSANDRA_4:
+ mode.validateSstableFormat(big);
+ Assertions.assertThatThrownBy(() ->
mode.validateSstableFormat(trie))
+ .isInstanceOf(ConfigurationException.class)
+ .hasMessageContaining("is not available when in
storage compatibility mode");
+ break;
+ default:
+ throw new AssertionError("Undefined behaviour for mode " +
mode);
+ }
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]