Skip to content

Commit

Permalink
STAR-582 avoid assertion when repairing 1 node cluster (#185)
Browse files Browse the repository at this point in the history
Porting patch DB-1511, riptano/apollo#627

Co-authored-by: Zhao Yang <[email protected]>
(cherry picked from commit 998eca0)
(cherry picked from commit 18a8ce9)
(cherry picked from commit 2b37f32)
(cherry picked from commit 2a29739)
(cherry picked from commit 3d9e3a6)
(cherry picked from commit a21dd64)
(cherry picked from commit 8044571)
  • Loading branch information
k-rus authored and djatnieks committed Jul 28, 2023
1 parent 473a3a1 commit f066fb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/java/org/apache/cassandra/repair/RepairRunnable.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ private NeighborsAndRanges getNeighborsAndRanges()
EndpointsForRange neighbors = ActiveRepairService.getNeighbors(keyspace, keyspaceLocalRanges, range,
options.getDataCenters(),
options.getHosts());
// local RF = 1 or given range is not part of local range, neighbors would be empty.
if (neighbors.isEmpty())
{
if (options.ignoreUnreplicatedKeyspaces())
Expand Down
5 changes: 4 additions & 1 deletion src/java/org/apache/cassandra/service/StorageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4207,8 +4207,11 @@ else if (option.isInLocalDCOnly())
Iterables.addAll(option.getRanges(), getLocalReplicas(keyspace).onlyFull().ranges());
}
}
if (option.getRanges().isEmpty() || Keyspace.open(keyspace).getReplicationStrategy().getReplicationFactor().allReplicas < 2)
if (option.getRanges().isEmpty() || Keyspace.open(keyspace).getReplicationStrategy().getReplicationFactor().allReplicas < 2
|| tokenMetadata.getAllEndpoints().size() < 2)
{
return Pair.create(0, Futures.immediateFuture(null));
}

int cmd = nextRepairCommand.incrementAndGet();
return Pair.create(cmd, ActiveRepairService.repairCommandExecutor().submit(createRepairTask(cmd, keyspace, option, listeners)));
Expand Down

0 comments on commit f066fb3

Please sign in to comment.