apache/cassandra · error · IllegalArgumentException

Specify only one of --older-than or --older-than-timestamp

Error message

Specify only one of --older-than or --older-than-timestamp

What it means

clearsnapshot supports two age-based filtering options: --older-than (a duration) and --older-than-timestamp (an ISO instant). They are mutually exclusive; passing both throws this IllegalArgumentException.

Source

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

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

        Long olderThanInSeconds = null;

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Keep only --older-than <duration> for relative cutoffs
  2. Keep only --older-than-timestamp <ISO-8601 instant> for absolute cutoffs
  3. Compute one from the other in your script before invoking nodetool

Example fix

// before
nodetool clearsnapshot --all --older-than 7d --older-than-timestamp 2026-01-01T00:00:00Z
// after
nodetool clearsnapshot --all --older-than 7d
Defensive patterns

Strategy: validation

Validate before calling

if olderThan and olderThanTimestamp: raise SystemExit("pick one of --older-than / --older-than-timestamp")

Try / catch

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

Prevention

When it happens

Trigger: Running e.g. `nodetool clearsnapshot --all --older-than 7d --older-than-timestamp 2026-01-01T00:00:00Z`.

Common situations: Scripts where both an explicit duration and a computed cutoff timestamp end up in the command line, or users unsure which option is canonical.

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/affbf6e2313ef011. Report an issue: GitHub.