apache/cassandra · error · IllegalArgumentException

Specifying snapshot name together with --older-than-timestam

Error message

Specifying snapshot name together with --older-than-timestamp flag is not allowed

What it means

IllegalArgumentException from ClearSnapshot.execute: mutually exclusive options were supplied — a snapshot name together with --older-than-timestamp. Clearing is either by exact name or by timestamp cutoff, never both, so the command rejects the invocation before touching any snapshots.

Source

Thrown at src/java/org/apache/cassandra/tools/nodetool/ClearSnapshot.java:76

    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.");
            }

        Long olderThanInSeconds = null;
        if (olderThan != null)
            // fail fast when it is not valid
            olderThanInSeconds = new DurationSpec.LongSecondsBound(olderThan).toSeconds();

        StringBuilder sb = new StringBuilder();

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Check the snapshot's creation time via `nodetool listsnapshots` and delete by name only if it predates the cutoff
  2. Use --all --older-than-timestamp <instant> for cutoff-based bulk deletion
  3. Remove --older-than-timestamp to delete the named snapshot regardless of age

Example fix

// before
nodetool clearsnapshot --snapshot snap1 --older-than-timestamp 2026-01-01T00:00:00Z
// after
nodetool clearsnapshot --snapshot snap1
Defensive patterns

Strategy: validation

Validate before calling

if snapName and olderThanTimestamp: raise SystemExit("name-based deletion cannot use --older-than-timestamp")

Try / catch

try { clearSnapshot(); }
catch (IllegalArgumentException e) { /* adjust flags */ }

Prevention

When it happens

Trigger: Running `nodetool clearsnapshot --snapshot snap1 --older-than-timestamp 2026-01-01T00:00:00Z`.

Common situations: Scripts combining point-in-time cleanup with a named snapshot; misunderstanding that the timestamp filters 'whether' the named snapshot is deleted.

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/52a89088c2fce4c2. Report an issue: GitHub.