Skip to content

Commit

Permalink
nodetool: scrub: support scrub_mode
Browse files Browse the repository at this point in the history
Add support for the scrubMode option.
Includes ABORT|SKIP|SEGREGATE|VALIDATE.

Fixes scylladb#263
Fixes scylladb#268

Signed-off-by: Benny Halevy <[email protected]>
  • Loading branch information
bhalevy committed Aug 18, 2021
1 parent 4ef8049 commit 46ad9a2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/java/org/apache/cassandra/service/StorageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2999,6 +2999,11 @@ public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkDa
}

public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, boolean reinsertOverflowedTTL, int jobs, String keyspaceName, String... tables) throws IOException, ExecutionException, InterruptedException
{
return scrub(disableSnapshot, skipCorrupted, "", checkData, reinsertOverflowedTTL, jobs, keyspaceName, tables);
}

public int scrub(boolean disableSnapshot, boolean skipCorrupted, String scrubMode, boolean checkData, boolean reinsertOverflowedTTL, int jobs, String keyspaceName, String... tables) throws IOException, ExecutionException, InterruptedException
{
CompactionManager.AllSSTableOpStatus status = CompactionManager.AllSSTableOpStatus.SUCCESSFUL;
for (ColumnFamilyStore cfStore : getValidColumnFamilies(true, false, keyspaceName, tables))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,11 @@ public interface StorageServiceMBean extends NotificationEmitter
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, String keyspaceName, String... tableNames) throws IOException, ExecutionException, InterruptedException;
@Deprecated
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, int jobs, String keyspaceName, String... columnFamilies) throws IOException, ExecutionException, InterruptedException;

@Deprecated
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, boolean reinsertOverflowedTTL, int jobs, String keyspaceName, String... columnFamilies) throws IOException, ExecutionException, InterruptedException;

public int scrub(boolean disableSnapshot, boolean skipCorrupted, String scrubMode, boolean checkData, boolean reinsertOverflowedTTL, int jobs, String keyspaceName, String... columnFamilies) throws IOException, ExecutionException, InterruptedException;

/**
* Verify (checksums of) the given keyspace.
* If tableNames array is empty, all CFs are verified.
Expand Down
8 changes: 4 additions & 4 deletions src/java/org/apache/cassandra/tools/NodeProbe.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ public int forceKeyspaceCleanup(int jobs, String keyspaceName, String... tables)
return ssProxy.forceKeyspaceCleanup(jobs, keyspaceName, tables);
}

public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, boolean reinsertOverflowedTTL, int jobs, String keyspaceName, String... tables) throws IOException, ExecutionException, InterruptedException
public int scrub(boolean disableSnapshot, boolean skipCorrupted, String scrubMode, boolean checkData, boolean reinsertOverflowedTTL, int jobs, String keyspaceName, String... tables) throws IOException, ExecutionException, InterruptedException
{
return ssProxy.scrub(disableSnapshot, skipCorrupted, checkData, reinsertOverflowedTTL, jobs, keyspaceName, tables);
return ssProxy.scrub(disableSnapshot, skipCorrupted, scrubMode, checkData, reinsertOverflowedTTL, jobs, keyspaceName, tables);
}

public int verify(boolean extendedVerify, String keyspaceName, String... tableNames) throws IOException, ExecutionException, InterruptedException
Expand Down Expand Up @@ -356,10 +356,10 @@ public void forceKeyspaceCleanup(PrintStream out, int jobs, String keyspaceName,
}
}

public void scrub(PrintStream out, boolean disableSnapshot, boolean skipCorrupted, boolean checkData, boolean reinsertOverflowedTTL, int jobs, String keyspaceName, String... tables) throws IOException, ExecutionException, InterruptedException
public void scrub(PrintStream out, boolean disableSnapshot, boolean skipCorrupted, String scrubMode, boolean checkData, boolean reinsertOverflowedTTL, int jobs, String keyspaceName, String... tables) throws IOException, ExecutionException, InterruptedException
{
checkJobs(out, jobs);
switch (ssProxy.scrub(disableSnapshot, skipCorrupted, checkData, reinsertOverflowedTTL, jobs, keyspaceName, tables))
switch (ssProxy.scrub(disableSnapshot, skipCorrupted, scrubMode, checkData, reinsertOverflowedTTL, jobs, keyspaceName, tables))
{
case 1:
failed = true;
Expand Down
7 changes: 6 additions & 1 deletion src/java/org/apache/cassandra/tools/nodetool/Scrub.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public class Scrub extends NodeToolCmd
description = "Skip corrupted partitions even when scrubbing counter tables. (default false)")
private boolean skipCorrupted = false;

@Option(title = "scrub_mode",
name = {"-m", "--mode"},
description = "How to handle corrupt data (one of: (ABORT|SKIP|SEGREGATE|VALIDATE); overrides 'skip_corrupted')")
private String scrubMode = "";

@Option(title = "no_validate",
name = {"-n", "--no-validate"},
description = "Do not validate columns using column validator")
Expand All @@ -69,7 +74,7 @@ public void execute(NodeProbe probe)
{
try
{
probe.scrub(System.out, disableSnapshot, skipCorrupted, !noValidation, reinsertOverflowedTTL, jobs, keyspace, tableNames);
probe.scrub(System.out, disableSnapshot, skipCorrupted, scrubMode, !noValidation, reinsertOverflowedTTL, jobs, keyspace, tableNames);
}
catch (IllegalArgumentException e)
{
Expand Down

0 comments on commit 46ad9a2

Please sign in to comment.