Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

- name: Run the cluster-free ecctool unit tests
working-directory: ecchronos-binary
run: python -m pytest --noconftest -p no:cacheprovider -v src/test/bin/test_ecctool_*.py src/test/bin/test_rest_timeout.py
run: python -m pytest --noconftest -p no:cacheprovider -v src/test/bin/test_ecctool_*.py src/test/bin/test_rest_timeout.py src/test/bin/test_primary_range_repair_lib.py

warm-maven-cache:
# Downloads all Maven dependencies once and saves ~/.m2/repository, so the matrix jobs below only restore it
Expand Down Expand Up @@ -127,6 +127,9 @@ jobs:
- name: "Incremental Repair integration tests"
goals: 'verify -P incremental-repair-integration-tests -Dit.cassandra.version=5.0 -DskipUTs'
artifacts_dir: "ecchronos-binary/target"
- name: "Primary Range Repair integration tests"
goals: 'verify -P primary-range-repair-integration-tests -Dit.cassandra.version=5.0 -DskipUTs'
artifacts_dir: "ecchronos-binary/target"
- name: "Jolokia Standalone integration 5.0"
goals: 'verify -P standalone-integration-tests -Dit.cassandra.version=5.0 -Dit.jolokia.enabled=true -DskipUTs'
artifacts_dir: "standalone-integration/target"
Expand All @@ -151,9 +154,15 @@ jobs:
- name: "Jolokia Incremental Repair integration tests"
goals: 'verify -P incremental-repair-integration-tests -Dit.cassandra.version=5.0 -Dit.jolokia.enabled=true -DskipUTs'
artifacts_dir: "ecchronos-binary/target"
- name: "Jolokia Primary Range Repair integration tests"
goals: 'verify -P primary-range-repair-integration-tests -Dit.cassandra.version=5.0 -Dit.jolokia.enabled=true -DskipUTs'
artifacts_dir: "ecchronos-binary/target"
- name: "Jolokia Incremental Repair integration tests - PEM"
goals: 'verify -P incremental-repair-integration-tests -Dit.cassandra.version=5.0 -Dit.jolokia.enabled=true -Dit.jmx.pem.enabled=true -DskipUTs'
artifacts_dir: "ecchronos-binary/target"
- name: "Jolokia Primary Range Repair integration tests - PEM"
goals: 'verify -P primary-range-repair-integration-tests -Dit.cassandra.version=5.0 -Dit.jolokia.enabled=true -Dit.jmx.pem.enabled=true -DskipUTs'
artifacts_dir: "ecchronos-binary/target"

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Version 1.1.4

* Add repair type `PRIMARY_RANGE` (`primary_range` in the configuration, `-r primary_range` in ecctool and `repairType=PRIMARY_RANGE` in the REST API) for scheduled and on-demand repairs. Every managed node runs a full repair of all its primary ranges in one repair session, like `nodetool repair -pr`, so repairing all nodes covers the ring once. `size_target` does not apply. It takes the same single slot table lock as incremental repair, so the two never run on a table at the same time, plus a single slot lock per datacenter involved, named so it does not collide with the vnode datacenter lock. `repair.lock_type` does not apply and it is not coordinated with vnode repair. The last successful run is recorded in `ecchronos.repair_history` as rows typed `PRIMARY_RANGE`, which the repair state of vnode repair skips explicitly (new `RepairHistoryProvider.lastSuccessfulRepair`). A table without such a row is taken for a new table, as for vnode repair, so its first repair waits for `initial_delay`. Scheduled primary range repair raises the `REPAIR_WARNING` and `REPAIR_ERROR` alarms at `repair.alarm.warn` and `repair.alarm.error`, with the source `PRIMARY_RANGE_ELAPSED` so they are separate from the vnode alarms of the same table, and ceases them when a repair has succeeded. Not for mixed-version clusters, older versions fail to list on-demand repairs while a `PRIMARY_RANGE` row exists - Issue #2005
* Fix flaky Jolokia agent download in cassandra-test-image: use repo1.maven.org instead of search.maven.org and retry curl on transient failures - Issue #1996
* Add `ecctool get-logging-level` and `ecctool set-logging-level` to read and change log levels of a running agent without restarting it, similar to `nodetool getlogginglevel`/`setlogginglevel`. Backed by new REST endpoints `GET /repair-management/v2/logging`, `GET /repair-management/v2/logging/{logger}` and `PUT /repair-management/v2/logging/{logger}` with body `{"level": "<level>"}`, applied through Spring Boot's LoggingSystem so the change also propagates to java.util.logging (embedded Tomcat). The level is one of TRACE, DEBUG, INFO, WARN, ERROR, OFF, or `reset` to clear the explicit level so the logger inherits again; `ROOT` can be read and set. An invalid level or logger name is rejected with a clear error and no change. Changes are in memory only and are lost on restart, apply to a single agent (select it with `--url`), and are unrestricted like the other REST endpoints, so a very verbose level such as TRACE on a busy agent can fill the disk - Issue #1999
* Fix NodeWorkerManager.removeNode() permanently pausing the node-worker pool: it called ThreadPoolTaskExecutor.stop(Runnable), which is the SmartLifecycle stop-with-callback and pauses the whole executor (nothing ever resumes it), and it also left the removed node's worker thread blocked in its event queue occupying a pool slot. After the first node removal (driver topology event or the periodic node reconciliation), every node added later got a worker that never ran, so it received no repair schedules and nothing was logged. The manager now keeps each worker's Future and cancels (interrupts) only that node's worker on removal, which ends the worker and returns its thread to the pool; the pool is never paused - Issue #1992
Expand Down
2 changes: 1 addition & 1 deletion application/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ keyspaces:
alarm:
warn: 8d
error: 10d
repair_type: vnode # vnode | parallel_vnode | incremental
repair_type: vnode # vnode | parallel_vnode | incremental | primary_range
size_target: 100m # Optional: enables sub-range repair
```

Expand Down
16 changes: 14 additions & 2 deletions application/src/main/resources/ecc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ repair:
##
## This setting only applies to repair_type "vnode" and "parallel_vnode". Incremental repair always uses its own
## fixed locks: a single lock per table, so that two incremental repairs of the same table never run
## concurrently, plus one lock per replica node. It is not affected by lock_type.
## concurrently, plus one lock per replica node. Primary range repair also has its own fixed locks: the same
## single lock per table plus one lock per datacenter. Neither is affected by lock_type.
##
lock_type: vnode
##
Expand All @@ -308,6 +309,10 @@ repair:
## With the defaults where repairs triggers once every 7 days for each table a warning alarm would be raised
## if the table has not been properly repaired within one full day.
##
## The alarms apply to all repair types except incremental, which has its own alarm for repairs that do not
## progress. For primary_range the alarms are raised for the node and table with the source PRIMARY_RANGE_ELAPSED,
## so they are separate from the alarms of vnode repair of the same table.
##
alarm:
##
## The class used for fault reporting
Expand Down Expand Up @@ -413,10 +418,17 @@ repair:
unit: MINUTES
##
## Specifies the default repair_type.
## Possible values are: vnode, parallel_vnode, incremental
## Possible values are: vnode, parallel_vnode, incremental, primary_range
## vnode = repair 1 vnode at a time (supports size_target to split the vnode further, in this case there will be 1 repair session per subrange)
## parallel_vnode = repair vnodes in parallel, this will combine vnodes into a single repair session per repair group
## incremental = repair vnodes incrementally (incremental repair)
## primary_range = full repair of all the primary ranges of the node in one repair session, like 'nodetool repair -pr'.
## Every managed node repairs its own primary ranges. size_target does not apply. Locks: a single lock per
## table (shared with incremental repair) and a single lock per datacenter involved. It does not use
## lock_type and is not coordinated with vnode repair. A table with no primary range repair in the
## repair history (within history_lookback_intervals) is taken for a new table, and its first repair
## waits for initial_delay, as for vnode repair. The warn and error alarms are raised when the last
## primary range repair is older than the alarm times, and ceased when a repair has succeeded.
##
repair_type: vnode
##
Expand Down
4 changes: 3 additions & 1 deletion application/src/main/resources/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ keyspaces:
# size_target:
##
## Specifies the default repair_type.
## Possible values are: vnode, parallel_vnode, incremental
## Possible values are: vnode, parallel_vnode, incremental, primary_range
## vnode = repair 1 vnode at a time (supports size_target to split the vnode further, in this case there will be 1 repair session per subrange)
## parallel_vnode = repair vnodes in parallel, this will combine vnodes into a single repair session per repair group
## incremental = repair vnodes incrementally (incremental repair)
## primary_range = full repair of all the primary ranges of the node in one repair session, like 'nodetool repair -pr'.
## Every managed node repairs its own primary ranges. size_target does not apply.
##
# repair_type: vnode
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import com.ericsson.bss.cassandra.ecchronos.core.repair.config.RepairConfiguration;
import com.ericsson.bss.cassandra.ecchronos.utils.enums.repair.RepairType;

import java.util.concurrent.TimeUnit;

Expand All @@ -27,6 +28,7 @@
import org.junit.Before;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import tools.jackson.dataformat.yaml.YAMLMapper;

/**
* Verifies the global-only history_lookback_intervals config and the initial_delay &lt; repair_interval startup
Expand Down Expand Up @@ -68,6 +70,33 @@ public void testHistoryLookbackIntervalsPropagatesToRepairConfiguration()
assertThat(repairConfiguration.getHistoryLookbackIntervals()).isEqualTo(5);
}

@Test
public void testRepairTypeIsParsedFromYamlForEveryRepairType()
{
YAMLMapper mapper = new YAMLMapper();

for (RepairType type : RepairType.values())
{
// Both lower case, as written in ecc.yml, and upper case must be accepted.
for (String written : new String[] {type.name().toLowerCase(java.util.Locale.US), type.name()})
{
GlobalRepairConfig config = mapper.readValue("repair_type: " + written, GlobalRepairConfig.class);

assertThat(config.getRepairType()).as("repair_type: %s", written).isEqualTo(type);
assertThat(config.asRepairConfiguration().getRepairType()).isEqualTo(type);
}
}
}

@Test
public void testPrimaryRangeRepairTypeIsAcceptedInTheConfigurationFile()
{
GlobalRepairConfig config = new YAMLMapper().readValue("repair_type: primary_range",
GlobalRepairConfig.class);

assertThat(config.getRepairType()).isEqualTo(RepairType.PRIMARY_RANGE);
}

@Test
public void testWarnsWhenInitialDelayBelowRepairInterval()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 2026 Telefonaktiebolaget LM Ericsson
*
* Licensed 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 com.ericsson.bss.cassandra.ecchronos.core.impl.locks;

import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairResource;
import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairResourceFactory;
import com.ericsson.bss.cassandra.ecchronos.core.state.ReplicaRepairGroup;
import com.ericsson.bss.cassandra.ecchronos.core.table.TableReference;
import com.google.common.base.Preconditions;
import java.util.HashSet;
import java.util.Set;

/**
* Repair resource factory for primary range repair.
* <p>
* A primary range repair repairs all the primary ranges of one node in a single repair session, like
* {@code nodetool repair -pr}. It produces two kinds of single slot locks:
* <ul>
* <li>A table lock, {@code keyspace.table}, which is the same lock incremental repair takes. Two primary range
* repairs of the same table, and a primary range repair and an incremental repair of the same table, can
* therefore not run at the same time, regardless of datacenter.</li>
* <li>One lock per datacenter involved in the repair. It has its own name prefix, so it is a different lock than
* the datacenter lock vnode repair takes (named after the datacenter only). Primary range repair and vnode
* repair are intentionally not coordinated with each other.</li>
* </ul>
* Locks are never taken per node. The locks of one repair are acquired together, all or nothing.
*/
public class PrimaryRangeRepairResourceFactory implements RepairResourceFactory
{
/**
* Datacenter placeholder for the table lock, shared with {@link IncrementalRepairResourceFactory}. The lock
* identity is the resource name alone, so this only needs to be stable and datacenter independent.
*/
private static final String GLOBAL_TABLE_LOCK_DC = "global";

/**
* Prefix of the datacenter lock names. Keeps the lock apart from the vnode datacenter lock, whose name is the
* datacenter name only, and from node and table locks.
*/
static final String DATA_CENTER_LOCK_PREFIX = "PrimaryRange-";

private static final int SINGLE_SLOT = 1;

private final TableReference myTableReference;

/**
* Constructor.
*
* @param tableReference the table being repaired; used to build the table lock resource.
*/
public PrimaryRangeRepairResourceFactory(final TableReference tableReference)
{
myTableReference = Preconditions.checkNotNull(tableReference, "Table reference must be set");
}

@Override
public final Set<RepairResource> getRepairResources(final ReplicaRepairGroup replicaRepairGroup)
{
Set<RepairResource> repairResources = new HashSet<>();

// Same name and slot count as the incremental table lock, so the two exclude each other per table.
String tableResourceName = myTableReference.getKeyspace() + "." + myTableReference.getTable();
repairResources.add(new RepairResource(GLOBAL_TABLE_LOCK_DC, tableResourceName, SINGLE_SLOT));

for (String dataCenter : replicaRepairGroup.getDataCenters())
{
repairResources.add(new RepairResource(dataCenter, DATA_CENTER_LOCK_PREFIX + dataCenter, SINGLE_SLOT));
}

return repairResources;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ public boolean hasTopologyChanged()
*/
public void startClusterWideJob(final RepairType repairType)
{
if (!distributesTokenRanges(repairType))
{
// Nothing to distribute: the job of every managed node already exists (scheduleClusterWideJob creates
// one per node) and each node repairs its own ranges. Writing rows for other nodes as well would start
// additional repairs.
return;
}
Map<LongTokenRange, ImmutableSet<DriverNode>> allTokenRanges =
myReplicationState.getTokenRanges(myTableReference, myCurrentNode);

Expand All @@ -223,6 +230,23 @@ public void startClusterWideJob(final RepairType repairType)
}
}

/**
* Whether a cluster-wide job of the given type hands out rows to other nodes, based on how the token ranges are
* assigned to them. Primary range repair does not: every managed node has its own job and repairs its own
* primary ranges, so extra rows would run extra repairs.
*
* @param repairType the repair type.
* @return true if rows are written for the nodes the token ranges are assigned to.
*/
private static boolean distributesTokenRanges(final RepairType repairType)
{
return switch (repairType)
{
case VNODE, PARALLEL_VNODE, INCREMENTAL -> true;
case PRIMARY_RANGE -> false;
};
}

private void distributeTokenRanges(
final Map<LongTokenRange, ImmutableSet<DriverNode>> allTokenRanges,
final Map<DriverNode, Set<LongTokenRange>> repairedRangesPerNode,
Expand Down Expand Up @@ -271,8 +295,8 @@ private void createClusterWideJob(final DriverNode node,
{
StoredRangeState rangeState = switch (repairType)
{
// Incremental repair is not tracked per token range.
case INCREMENTAL -> new StoredRangeState(0, Collections.emptySet());
// Incremental and primary range repair are not tracked per token range.
case INCREMENTAL, PRIMARY_RANGE -> new StoredRangeState(0, Collections.emptySet());
case VNODE, PARALLEL_VNODE ->
new StoredRangeState(allTokenRanges(remainingRanges, repairedRanges).hashCode(), repairedRanges);
};
Expand Down
Loading
Loading