apache/cassandra · error · IllegalArgumentException
Specify only one of snapshot name or --all
Error message
Specify only one of snapshot name or --all
What it means
`nodetool clearsnapshot` treats a named snapshot and the --all flag as mutually exclusive: --all already implies deleting every snapshot, so a name alongside it is ambiguous. Supplying both throws this IllegalArgumentException.
Source
Thrown at src/java/org/apache/cassandra/tools/nodetool/ClearSnapshot.java:67
@Option(paramLabel = "clear_all_snapshots", names = "--all", description = "Removes all snapshots")
private boolean clearAllSnapshots = false;
@Option(paramLabel = "older_than", names = "--older-than", description = "Clear snapshots older than specified time period.")
private String olderThan;
@Option(paramLabel = "older_than_timestamp", names = "--older-than-timestamp",
description = "Clear snapshots older than specified timestamp. It has to be a string in ISO format, for example '2022-12-03T10:15:30Z'")
private String olderThanTimestamp;
@Override
public void execute(NodeProbe probe)
{
if (snapshotName.isEmpty() && !clearAllSnapshots)
throw new IllegalArgumentException("Specify snapshot name or --all");
if (!snapshotName.isEmpty() && clearAllSnapshots)
throw new IllegalArgumentException("Specify only one of snapshot name or --all");
if (olderThan != null && olderThanTimestamp != null)
throw new IllegalArgumentException("Specify only one of --older-than or --older-than-timestamp");
if (!snapshotName.isEmpty() && olderThan != null)
throw new IllegalArgumentException("Specifying snapshot name together with --older-than flag is not allowed");
if (!snapshotName.isEmpty() && olderThanTimestamp != null)
throw new IllegalArgumentException("Specifying snapshot name together with --older-than-timestamp flag is not allowed");
if (olderThanTimestamp != null)
try
{
Instant.parse(olderThanTimestamp);
}
catch (DateTimeParseException ex)
{
throw new IllegalArgumentException("Parameter --older-than-timestamp has to be a valid instant in ISO format.");View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Use only --all to delete every snapshot
- Use only --snapshot <name> (repeatable per snapshot name) to delete specific ones
- If the goal is selective cleanup, run clearsnapshot once per snapshot name instead of adding --all
Example fix
// before nodetool clearsnapshot --snapshot snap1 --all // after nodetool clearsnapshot --snapshot snap1
Defensive patterns
Strategy: validation
Validate before calling
if snapName && allFlag: raise SystemExit("use --snapshot OR --all, not both") Try / catch
try { clearSnapshot(); }
catch (IllegalArgumentException e) { /* fix flags */ } Prevention
- Choose one deletion mode per invocation
- Review script flag accumulation
- Prefer --all only after explicit confirmation
When it happens
Trigger: Running `nodetool clearsnapshot --snapshot my_snap --all`.
Common situations: Scripts accumulating flags over time, users wanting 'this snapshot and all others' without realizing --all subsumes the name.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- Specify snapshot name or --all
- Specify only one of --older-than or --older-than-timestamp
- Specifying snapshot name together with --older-than flag is
- Specifying snapshot name together with --older-than-timestam
- Can not parse replication factor %s
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/1f622100598edc40.
Report an issue: GitHub.