Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
7fe3853
autorepair v2 framework
jaydeepkumar1984 May 11, 2024
c849deb
cr
jaydeepkumar1984 Jul 23, 2024
ca1891f
chop the repair API
jaydeepkumar1984 Jul 27, 2024
3ad85dd
Add a test case that ensures LocalStrategy.class is ignored from bein…
kzalys Aug 16, 2024
060e390
Shuffle keyspaces and tables when running auto-repair
kzalys Aug 16, 2024
3dcebe6
Prevent node restart from scheduling a premature auto-repair cycle
kzalys Aug 17, 2024
dd54c74
Implement SucceededTokenRangesCount and FailedTokenRangesCount metric…
kzalys Aug 17, 2024
d1501fa
Add intial_scheduler_delay option to AutoRepairConfig
kzalys Aug 17, 2024
50110b6
Implement nodetool sstablerepairedset
kzalys Aug 18, 2024
cfc6bde
Change SkippedTablesCount metric to SkippedTokenRangesCount
kzalys Aug 25, 2024
0271718
config description
jaydeepkumar1984 Aug 26, 2024
99acef9
Implement repair retries for auto-repair scheduler
kzalys Aug 29, 2024
b071c59
Extend nodetool sstablerepairedset to affect all keyspaces when no ke…
kzalys Aug 30, 2024
4e4485f
Make repair session timeout configurable
jaydeepkumar1984 Aug 30, 2024
f51a1ef
Comments from Joshua M
jaydeepkumar1984 Sep 6, 2024
095d321
AutoRepair scheduler InJvm dtest
jaydeepkumar1984 Sep 7, 2024
0ac15d9
Increase CircleCI parallelism 1-->4
jaydeepkumar1984 Sep 24, 2024
b39b58f
Fix a test case failure org.apache.cassandra.schema.SchemaKeyspaceTes…
jaydeepkumar1984 Sep 24, 2024
f69d7d7
Trigger automatic CircleCI jobs
jaydeepkumar1984 Sep 24, 2024
461f18a
CircleCI ask for a manual approval
jaydeepkumar1984 Sep 24, 2024
4b58140
Fix the JMXStandardsTest::interfaces
kzalys Sep 25, 2024
91911b4
Circle AutoStart J8 tests
jaydeep1984 Sep 25, 2024
938d8d3
Allow IR to run with MVs and CDC if write path replay is disabled
kzalys Sep 26, 2024
8a348d7
Add a nodetool command to get the nodes going through repair
kzalys Sep 27, 2024
2c200a8
Adjust a couple of default configuration values
jaydeepkumar1984 Sep 27, 2024
1648097
Rename EMPTY --> NONE for Nodetool autorepairstatus command
jaydeepkumar1984 Sep 27, 2024
0881ee7
Minor code refactoring to simplify the repair API by removing the SLE…
jaydeepkumar1984 Sep 28, 2024
9040b9c
Adjust AutoRepair on 5.0
jaydeepkumar1984 Sep 30, 2024
08ec734
Fix unit test cases DescribeStatementTest & SchemaCQLHelperTest
jaydeepkumar1984 Sep 30, 2024
6d30102
Safeguard the setup call to ensure it it done only once
jaydeepkumar1984 Sep 30, 2024
d215870
Fix InJvm test AutoRepairSchedulerTest
jaydeepkumar1984 Oct 1, 2024
a5cdd4f
Unit test failures AutoRepairTest.java
jaydeepkumar1984 Oct 1, 2024
5ed34ea
5.0 formatting
jaydeepkumar1984 Oct 3, 2024
ff50053
Fix flaky AutoRepairTest::testSetup and AutoRepairTest::testSafeGuard…
jaydeepkumar1984 Oct 8, 2024
82733d7
Fix a test failure inside pylib/cqlshlib/test/test_cqlsh_output.py
kzalys Oct 8, 2024
8c6d17c
AutoRepair nodetool throws an exception if the framework is disabled
jaydeepkumar1984 Oct 9, 2024
df5b922
Run repair on bootstrapped if configured to do so
jaydeepkumar1984 Oct 9, 2024
242d082
Fix broken AutoRepairSchedulerTest.java & AutoRepairStatusTest.java
jaydeepkumar1984 Oct 9, 2024
819771f
Comments from Chris Lohfink: nix automated_ and a typo
jaydeepkumar1984 Oct 9, 2024
0cf7a57
Comments from Chris Lohfink: System::currentTimeMillis --> Clock.Glob…
jaydeepkumar1984 Oct 9, 2024
5828bc9
Update IAutoRepairTokenRangeSplitter API to be more flexible
tolbertam Sep 25, 2024
a69a71a
Fix a corner-case bug NPE org.apache.cassandra.repair.autorepair.Auto…
jaydeepkumar1984 Oct 12, 2024
d58dc73
Update documentation for the newly added metric
jaydeepkumar1984 Oct 14, 2024
d214ad6
Fix the failed StorageServiceServerTest test cases
jaydeepkumar1984 Oct 15, 2024
c641fd4
Formatting: Add a new line towards the end SystemDistributedKeyspace.…
jaydeepkumar1984 Oct 15, 2024
e340bac
Formatting: Add a new line towards the end IAutoRepairTokenRangeSplit…
jaydeepkumar1984 Oct 15, 2024
2c007e0
Formatting: YamlConfigurationLoader.java & CassandraStreamReceiver.java
jaydeepkumar1984 Oct 15, 2024
a8fb1aa
Revert .circleci/config.yaml settings
jaydeepkumar1984 Oct 17, 2024
c984d46
Code formatting: Remove Group from naming
jaydeepkumar1984 Oct 27, 2024
ab452a6
Enable repair scheduler through nodetool
jaydeepkumar1984 Oct 28, 2024
e1357c1
Increment system_distributed GENERATION
jaydeepkumar1984 Oct 29, 2024
793683d
Option to disable write path during streaming for MV enabled tables; …
jaydeepkumar1984 Nov 4, 2024
c888f73
cr from tolbertam - replace MV/CDC repair replay JVM properties to ya…
jaydeepkumar1984 Nov 4, 2024
206637c
code formatting for StreamOperation.java
jaydeepkumar1984 Nov 5, 2024
5fa4015
ant checkstyle: toLowerCase-->toLowerCaseLocalized
jaydeepkumar1984 Nov 6, 2024
c6bd7df
code formatting: DatabaseDescriptor.java
jaydeepkumar1984 Nov 6, 2024
f9f6971
Rename AutoRepair --> UnifiedRepair
jaydeepkumar1984 Nov 21, 2024
5c7f394
Revert "Rename AutoRepair --> UnifiedRepair"
jaydeep1984 Nov 21, 2024
2f52e29
Implement preview repaired metrics
kzalys Nov 7, 2024
03c0cac
Improve preview repair metrics
kzalys Nov 21, 2024
cee8966
Update src/java/org/apache/cassandra/repair/autorepair/AutoRepairConf…
kzalys Nov 26, 2024
2f336de
Address comments
kzalys Dec 4, 2024
7abfa06
Fix preview repair options for system_schema ks
kzalys Dec 4, 2024
f6d3983
Implement BytesPreviewed and TokenRangesPreviewed metrics
kzalys Dec 4, 2024
8043b83
Update test/unit/org/apache/cassandra/repair/autorepair/AutoRepairPar…
kzalys Dec 6, 2024
6a14363
Address comments
kzalys Dec 6, 2024
497563f
Update metrics docs
kzalys Dec 6, 2024
a27ea6f
Update metrics
kzalys Dec 6, 2024
5c718c4
Merge pull request #8 from jaydeepkumar1984/trunk_cep_37_cassandra_20046
jaydeepkumar1984 Dec 10, 2024
daf4cfe
UnrepairedBytesBasedTokenRangeSplitter prototype
tolbertam Nov 3, 2024
0bcf9d7
Add Repair range splitter
clohfink Nov 7, 2024
7eb0059
add assignment priorirty to table options
clohfink Nov 8, 2024
ba729c3
reorder with DefaultAutoRepairTokenSplitter
clohfink Nov 8, 2024
dca85ba
add tests for partition count estimation
clohfink Nov 8, 2024
eb08310
Add license header to RepairRangeSplitter
tolbertam Nov 10, 2024
0c14b85
Simplify access of repair_type_overrides, key by String
tolbertam Nov 10, 2024
f53ae5c
Allow partial repair of range, factor in total bytes for IR
tolbertam Nov 11, 2024
3a8643b
update warnings based on repair type
clohfink Nov 14, 2024
fe799c5
Move size comparison up so priority can be factored in
tolbertam Nov 27, 2024
f909af5
Various cleanup
tolbertam Nov 27, 2024
451a58d
Handle EmpySSTableScanner being returned from getScanner
tolbertam Nov 27, 2024
104094a
Minor refactoring around bytesPerSubrange, logging
tolbertam Nov 27, 2024
06de4a3
Cleanup logging of repair assignments
tolbertam Nov 27, 2024
c72e867
Remove UnrepairedBytesBasedTokenRangeSplitter
tolbertam Nov 30, 2024
1c1b8aa
Refactor RepairRangeSplitter interface to accept all keyspaces
tolbertam Nov 30, 2024
0fc2985
Naming consistency
tolbertam Nov 30, 2024
9ac5fa8
Use memtable size for memtable only
tolbertam Nov 30, 2024
9a7037c
Fix dtest
tolbertam Dec 2, 2024
def87fc
Refactor IAutoRepairTokenRangeSplitter to be Iterator based
tolbertam Dec 2, 2024
3ab7de6
Add more priority and range splitter tests
tolbertam Dec 2, 2024
4c6c23f
Refactor a missed change during the rebase
jaydeepkumar1984 Dec 10, 2024
bf0481c
Set thread name based on RepairType.getConfigName()
tolbertam Dec 7, 2024
0103a1a
Flatten the auto_repair table property
jaydeepkumar1984 Dec 8, 2024
46ca72c
Fix ant checkstyle errors
jaydeepkumar1984 Dec 10, 2024
efb9793
Ignore keyspaces with MetaStrategy
jaydeepkumar1984 Dec 10, 2024
51e86d5
Adjust BigTableScanner.getScanner as per 5.1 API set
jaydeep1984 Dec 10, 2024
d784844
Fix antcheckstyle
jaydeepkumar1984 Dec 10, 2024
da3e023
Fix ant test-latest failures for RepairRangeSplitterTest-latest_jdk17…
jaydeepkumar1984 Dec 12, 2024
607b1a1
utest: calculate expected tables dynamically instead of a fixed value
tolbertam Dec 15, 2024
533a1ef
Merge pull request #9 from jaydeepkumar1984/trunk_cep_37_cassandra_20047
jaydeepkumar1984 Dec 17, 2024
ab71a15
Ignore repair for system_traces keyspace
jaydeepkumar1984 Dec 18, 2024
851f2c6
CR from Andy T
jaydeepkumar1984 Dec 19, 2024
4939750
Merge pull request #12 from jaydeepkumar1984/trunk_cep_37_cassandra_2…
jaydeepkumar1984 Dec 19, 2024
ff67c3a
Fix diff40
jaydeepkumar1984 Dec 19, 2024
8243151
Fix diff41
jaydeepkumar1984 Dec 19, 2024
6c45efd
Implement minimum repair task duration setting for auto-repair scheduler
kzalys Dec 20, 2024
0caa563
Cleanup
kzalys Dec 20, 2024
9f555fc
Cleanup
kzalys Dec 20, 2024
3c6bc25
Address comment
kzalys Dec 21, 2024
c06acaf
Remove unused imports
jaydeepkumar1984 Dec 21, 2024
c08b8d9
formatting
jaydeepkumar1984 Dec 21, 2024
9b8a582
Convert the metrics to TableMeter
jaydeepkumar1984 Dec 20, 2024
c265030
Add a global type=ColumnFamily
jaydeep1984 Dec 20, 2024
d19138a
Remove an extra empty line
jaydeep1984 Dec 20, 2024
cfc6705
Revert the cassandra-4.x.xml changes
jaydeepkumar1984 Dec 20, 2024
de582fd
gauge compatible meter
tolbertam Dec 21, 2024
4ba619e
Merge pull request #14 from jaydeepkumar1984/trunk_cep_37_JMXCompatab…
jaydeepkumar1984 Dec 22, 2024
59a95cd
Merge pull request #16 from jaydeepkumar1984/trunk_cep_37_cassandra_2…
jaydeepkumar1984 Dec 22, 2024
c210d72
DO NOT COMMIT circleci
clohfink Nov 18, 2024
25802d1
add guardrail for multiple version repairs being blocked
clohfink Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 107 additions & 107 deletions .circleci/config.yml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions conf/cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,13 @@ report_unconfirmed_repaired_data_mismatches: false
# Materialized views are considered experimental and are not recommended for production use.
materialized_views_enabled: false

# Specify whether Materialized View mutations are replayed through the write path on streaming, e.g. repair.
# When enabled, Materialized View data streamed to the destination node will be written into commit log first. When setting to false,
# the streamed Materialized View data is written into SSTables just the same as normal streaming. The default is true.
# If this is set to false, streaming will be considerably faster however it's possible that, in extreme situations
# (losing > quorum # nodes in a replica set), you may have data in your SSTables that never makes it to the Materialized View.
# materialized_views_on_repair_enabled: true

# Enables SASI index creation on this node.
# SASI indexes are considered experimental and are not recommended for production use.
sasi_indexes_enabled: false
Expand Down
65 changes: 63 additions & 2 deletions doc/modules/cassandra/pages/managing/operating/metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,19 @@ during validation.
|PartitionsValidated |Histogram |Histogram over the number of partitions
read during validation.

|BytesAnticompacted |Counter |How many bytes we anticompacted.
|BytesAnticompacted |Meter |How many bytes we anticompacted.

|BytesMutatedAnticompaction |Counter |How many bytes we avoided
|BytesMutatedAnticompaction |Meter |How many bytes we avoided
anticompacting because the sstable was fully contained in the repaired
range.

|BytesPreviewed |Meter |Estimated number of bytes that were scanned for local replica during preview repair

|BytesPreviewedDesynchronized |Meter |Number of desynchronized bytes that were detected among all replicas during preview repair

|TokenRangesPreviewedDesynchronized |Meter |Number of token ranges among all replicas where desynchronization was found
during preview repair. These ranges would need to be streamed during subsequent repair.

|MutatedAnticompactionGauge |Gauge<Double> |Ratio of bytes mutated vs
total bytes repaired.
|===
Expand Down Expand Up @@ -1078,6 +1085,60 @@ partitions processed per logged batch
partitions processed per unlogged batch
|===

== Automated Repair Metrics

Metrics specifc to automated repair.

Reported name format:

*Metric Name*::
`org.apache.cassandra.metrics.AutoRepair.<MetricName>`
*JMX MBean*::
`org.apache.cassandra.metrics:type=AutoRepair name=<MetricName> repairType=<RepairType>`

[cols=",,",options="header",]
|===
|Name |Type |Description
|RepairsInProgress |Gauge<Integer> |Repair is in progress
on the node

|NodeRepairTimeInSec |Gauge<Integer> |Time taken to repair
the node in seconds

|ClusterRepairTimeInSec |Gauge<Integer> |Time taken to repair
the entire Cassandra cluster in seconds

|LongestUnrepairedSec |Gauge<Integer> |Time since the last repair
ran on the node in seconds

|SucceededTokenRangesCount |Gauge<Integer> |Number of token ranges successfully repaired on the node

|FailedTokenRangesCount |Gauge<Integer> |Number of token ranges failed to repair on the node

|SkippedTokenRangesCount |Gauge<Integer> |Number of token ranges skipped
on the node

|SkippedTablesCount |Gauge<Integer> |Number of tables skipped
on the node

|TotalMVTablesConsideredForRepair |Gauge<Integer> |Number of materialized
views considered on the node

|TotalDisabledRepairTables |Gauge<Integer> |Number of tables on which
the automated repair has been disabled on the node

|RepairTurnMyTurn |Counter |Represents the node's turn to repair

|RepairTurnMyTurnDueToPriority |Counter |Represents the node's turn to repair
due to priority set in the automated repair

|RepairTurnMyTurnForceRepair |Counter |Represents the node's turn to repair
due to force repair set in the automated repair


|===


== JVM Metrics

JVM metrics such as memory and garbage collection statistics can either
Expand Down
3 changes: 2 additions & 1 deletion pylib/cqlshlib/test/test_cqlsh_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,8 @@ def test_describe_columnfamily_output(self):
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair = 'BLOCKING'
AND speculative_retry = '99p';""" % quote_name(get_keyspace()))
AND speculative_retry = '99p'
AND auto_repair = {'full_enabled': 'true', 'incremental_enabled': 'true', 'preview_repaired_enabled': 'true', 'priority': '0'};""" % quote_name(get_keyspace()))

with cqlsh_testrun(tty=True, env=self.default_env) as c:
for cmdword in ('describe table', 'desc columnfamily'):
Expand Down
12 changes: 12 additions & 0 deletions src/java/org/apache/cassandra/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;

import org.apache.cassandra.repair.autorepair.AutoRepairConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -353,6 +355,10 @@ public MemtableOptions()
// The number of executors to use for building secondary indexes
public volatile int concurrent_index_builders = 2;

// at least 20% of disk must be unused to run incremental repair
// if you want to disable this feature (the recommendation is not to, but if you want to disable it for whatever reason) then set the ratio to 0.0
public volatile double incremental_repair_disk_headroom_reject_ratio = 0.2;

/**
* @deprecated retry support removed on CASSANDRA-10992
*/
Expand Down Expand Up @@ -417,6 +423,7 @@ public static class SSTableConfig
// When false, it behaves the same as normal streaming.
public volatile boolean cdc_on_repair_enabled = true;
public String cdc_raw_directory;
public boolean mixed_version_repairs_enabled = true;
@Replaces(oldName = "cdc_total_space_in_mb", converter = Converters.MEBIBYTES_DATA_STORAGE_INT, deprecated = true)
public DataStorageSpec.IntMebibytesBound cdc_total_space = new DataStorageSpec.IntMebibytesBound("0MiB");
@Replaces(oldName = "cdc_free_space_check_interval_ms", converter = Converters.MILLIS_DURATION_INT, deprecated = true)
Expand Down Expand Up @@ -595,6 +602,10 @@ public static class SSTableConfig
@Replaces(oldName = "enable_materialized_views", converter = Converters.IDENTITY, deprecated = true)
public boolean materialized_views_enabled = false;

// When true, materialized views data in SSTable go through commit logs during internodes streaming, e.g. repair
// When false, it behaves the same as normal streaming.
public volatile boolean materialized_views_on_repair_enabled = true;

@Replaces(oldName = "enable_transient_replication", converter = Converters.IDENTITY, deprecated = true)
public boolean transient_replication_enabled = false;

Expand Down Expand Up @@ -947,6 +958,7 @@ public static void setClientMode(boolean clientMode)

public volatile boolean password_validator_reconfiguration_enabled = true;
public volatile CustomGuardrailConfig password_validator = new CustomGuardrailConfig();
public volatile AutoRepairConfig auto_repair = new AutoRepairConfig();

/**
* The variants of paxos implementation and semantics supported by Cassandra.
Expand Down
32 changes: 32 additions & 0 deletions src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
import org.apache.cassandra.locator.InetAddressAndPort;
import org.apache.cassandra.locator.Replica;
import org.apache.cassandra.locator.SeedProvider;
import org.apache.cassandra.repair.autorepair.AutoRepairConfig;
import org.apache.cassandra.security.AbstractCryptoProvider;
import org.apache.cassandra.security.EncryptionContext;
import org.apache.cassandra.security.JREProvider;
Expand Down Expand Up @@ -4206,6 +4207,16 @@ public static void setMaterializedViewsEnabled(boolean enableMaterializedViews)
conf.materialized_views_enabled = enableMaterializedViews;
}

public static boolean isMaterializedViewsOnRepairEnabled()
{
return conf.materialized_views_on_repair_enabled;
}

public static void setMaterializedViewsOnRepairEnabled(boolean val)
{
conf.materialized_views_on_repair_enabled = val;
}

public static boolean getSASIIndexesEnabled()
{
return conf.sasi_indexes_enabled;
Expand Down Expand Up @@ -5349,4 +5360,25 @@ public static boolean isPasswordValidatorReconfigurationEnabled()
{
return conf.password_validator_reconfiguration_enabled;
}

public static AutoRepairConfig getAutoRepairConfig()
{
return conf.auto_repair;
}

public static double getIncrementalRepairDiskHeadroomRejectRatio()
{
return conf.incremental_repair_disk_headroom_reject_ratio;
}

public static void setIncrementalRepairDiskHeadroomRejectRatio(double value)
{
conf.incremental_repair_disk_headroom_reject_ratio = value;
}

@VisibleForTesting
public static void setPartitioner(String name)
{
partitioner = FBUtilities.newPartitioner(name);
}
}
3 changes: 2 additions & 1 deletion src/java/org/apache/cassandra/config/DurationSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.cassandra.config;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
Expand All @@ -41,7 +42,7 @@
* users the opportunity to be able to provide config with a unit of their choice in cassandra.yaml as per the available
* options. (CASSANDRA-15234)
*/
public abstract class DurationSpec
public abstract class DurationSpec implements Serializable
{
/**
* The Regexp used to parse the duration provided as String.
Expand Down
16 changes: 16 additions & 0 deletions src/java/org/apache/cassandra/config/GuardrailsOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@ public int getMaterializedViewsPerTableWarnThreshold()
return config.materialized_views_per_table_warn_threshold;
}

@Override
public boolean getMixedVersionRepairsEnabled()
{
return config.mixed_version_repairs_enabled;
}

@Override
public boolean setMixedVersionRepairsEnabled(boolean enabled)
{
updatePropertyWithLogging("mixed_version_repairs_enabled",
enabled,
() -> config.mixed_version_repairs_enabled,
x -> config.mixed_version_repairs_enabled = x);
return enabled;
}

@Override
public int getPartitionKeysInSelectWarnThreshold()
{
Expand Down
3 changes: 2 additions & 1 deletion src/java/org/apache/cassandra/config/ParameterizedClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.lang.reflect.Constructor;
import java.util.Collections;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

Expand All @@ -30,7 +31,7 @@
import static org.apache.cassandra.utils.Shared.Scope.SIMULATION;

@Shared(scope = SIMULATION)
public class ParameterizedClass
public class ParameterizedClass implements Serializable
{
public static final String CLASS_NAME = "class_name";
public static final String PARAMETERS = "parameters";
Expand Down
7 changes: 7 additions & 0 deletions src/java/org/apache/cassandra/cql3/UntypedResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ public long getLong(String column)
return LongType.instance.compose(data.get(column));
}

// this function will return the default value if the row doesn't have that column or the column data is null
// This function is used to avoid the nullpointerexception
public long getLong(String column, long ifNull) {
ByteBuffer bytes = data.get(column);
return bytes == null ? ifNull : LongType.instance.compose(bytes);
}

public <T> Set<T> getSet(String column, AbstractType<T> type)
{
ByteBuffer raw = data.get(column);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public abstract class ModificationStatement implements CQLStatement.SingleKeyspa
public static final String CUSTOM_EXPRESSIONS_NOT_ALLOWED =
"Custom index expressions cannot be used in WHERE clauses for UPDATE or DELETE statements";

private static final ColumnIdentifier CAS_RESULT_COLUMN = new ColumnIdentifier("[applied]", false);
public static final ColumnIdentifier CAS_RESULT_COLUMN = new ColumnIdentifier("[applied]", false);

protected final StatementType type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.apache.cassandra.cql3.statements.PropertyDefinitions;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.schema.AutoRepairParams;
import org.apache.cassandra.schema.CachingParams;
import org.apache.cassandra.schema.CompactionParams;
import org.apache.cassandra.schema.CompressionParams;
Expand Down Expand Up @@ -151,6 +152,9 @@ private TableParams build(TableParams.Builder builder)
if (hasOption(READ_REPAIR))
builder.readRepair(ReadRepairStrategy.fromString(getString(READ_REPAIR)));

if (hasOption(Option.AUTO_REPAIR))
builder.automatedRepair(AutoRepairParams.fromMap(getMap(Option.AUTO_REPAIR)));

return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ private static void mutateFullyContainedSSTables(ColumnFamilyStore cfs,

Set<SSTableReader> fullyContainedSSTables = findSSTablesToAnticompact(sstableIterator, normalizedRanges, sessionID);

cfs.metric.bytesMutatedAnticompaction.inc(SSTableReader.getTotalBytes(fullyContainedSSTables));
cfs.metric.bytesMutatedAnticompaction.mark(SSTableReader.getTotalBytes(fullyContainedSSTables));
cfs.getCompactionStrategyManager().mutateRepaired(fullyContainedSSTables, UNREPAIRED_SSTABLE, sessionID, isTransient);
// since we're just re-writing the sstable metdata for the fully contained sstables, we don't want
// them obsoleted when the anti-compaction is complete. So they're removed from the transaction here
Expand Down Expand Up @@ -1724,7 +1724,7 @@ private void doAntiCompaction(ColumnFamilyStore cfs,
// repairedAt values for these, we still avoid anti-compacting already repaired sstables, as we currently don't
// make use of any actual repairedAt value and splitting up sstables just for that is not worth it at this point.
Set<SSTableReader> unrepairedSSTables = sstables.stream().filter((s) -> !s.isRepaired()).collect(Collectors.toSet());
cfs.metric.bytesAnticompacted.inc(SSTableReader.getTotalBytes(unrepairedSSTables));
cfs.metric.bytesAnticompacted.mark(SSTableReader.getTotalBytes(unrepairedSSTables));
Collection<Collection<SSTableReader>> groupedSSTables = cfs.getCompactionStrategyManager().groupSSTablesForAntiCompaction(unrepairedSSTables);

// iterate over sstables to check if the full / transient / unrepaired ranges intersect them.
Expand Down
34 changes: 34 additions & 0 deletions src/java/org/apache/cassandra/db/guardrails/Guardrails.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
import org.apache.cassandra.locator.InetAddressAndPort;
import org.apache.cassandra.service.ClientState;
import org.apache.cassandra.service.disk.usage.DiskUsageBroadcaster;
import org.apache.cassandra.tcm.ClusterMetadata;
import org.apache.cassandra.tcm.membership.Directory;
import org.apache.cassandra.tcm.membership.NodeId;
import org.apache.cassandra.tcm.membership.NodeVersion;
import org.apache.cassandra.utils.MBeanWrapper;
import org.apache.cassandra.utils.btree.BTreeMap;

import static java.lang.String.format;

Expand Down Expand Up @@ -289,6 +294,23 @@ public final class Guardrails implements GuardrailsMBean
state -> CONFIG_PROVIDER.getOrCreate(state).getAllowFilteringEnabled(),
"Querying with ALLOW FILTERING");

/**
* Guardrail disabling repairs when there are mixed versions
*/
public static final EnableFlag mixedRepairsEnabled =
new EnableFlag("mixed_version_repairs",
"Mixed mode repairs and streaming adds many unknowns and additional performance impacts during upgrades.",
state -> {
if (CONFIG_PROVIDER.getOrCreate(state).getMixedVersionRepairsEnabled())
return true;
Directory directory = ClusterMetadata.current().directory;
Set<NodeId> nodes = directory.states.keySet();
BTreeMap<NodeId, NodeVersion> versions = directory.versions;
NodeVersion version = versions.get(nodes.iterator().next());
return nodes.stream().allMatch(node -> versions.get(node).equals(version));
},
"Running repairs during mixed Cassandra versions");

/**
* Guardrail disabling setting SimpleStrategy via keyspace creation or alteration
*/
Expand Down Expand Up @@ -594,6 +616,18 @@ public void setKeyspacesThreshold(int warn, int fail)
DEFAULT_CONFIG.setKeyspacesThreshold(warn, fail);
}

@Override
public boolean getMixedVersionRepairsEnabled()
{
return DEFAULT_CONFIG.getMixedVersionRepairsEnabled();
}

@Override
public void setMixedVersionRepairsEnabled(boolean enabled)
{
DEFAULT_CONFIG.setMixedVersionRepairsEnabled(enabled);
}

@Override
public int getTablesWarnThreshold()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public interface GuardrailsConfig
*/
int getPartitionKeysInSelectFailThreshold();

/**
* @return if repairs during mixed versions are allowed
*/
boolean getMixedVersionRepairsEnabled();
boolean setMixedVersionRepairsEnabled(boolean enabled);

/**
* @return The threshold to fail when creating more materialized views per table than threshold.
*/
Expand Down
Loading