apache/cassandra · error · java.lang.IllegalStateException

Can't abort a %s operation unless it has failed

Error message

Can't abort a %s operation unless it has failed

What it means

abortHelper only allows aborting a decommission/remove/move of the LOCAL node when StorageService is in the expected failed operation mode. If the operation mode does not match the expected mode for that abort kind, the operation is considered still running (or absent) and IllegalStateException is thrown. Local aborts are only meaningful for failed operations.

Source

Thrown at src/java/org/apache/cassandra/tcm/sequences/SingleNodeSequences.java:281

                // there is no ongoing sequence with the given kind, but storage service operation mode is set, clear it
                logger.debug("There is no ongoing {} sequence for this node, but operation mode is {} - clearing transient mode", kind, ssMode);
                StorageService.instance.clearTransientMode();
                return;
            }
            else
            {
                String msg = String.format("No %s operation in progress for %s, can't abort (%s)", kind, toAbort, sequence);
                logger.info(msg);
                throw new IllegalStateException(msg);
            }
        }
        if (toAbort.equals(metadata.myNodeId()))
        {
            if (ssMode != null && StorageService.instance.operationMode() != ssMode)
            {
                String msg = String.format("Can't abort a %s operation unless it has failed", kind);
                logger.info(msg);
                throw new IllegalStateException(msg);
            }
            StorageService.instance.clearTransientMode();
        }
        else if (Gossiper.instance.isAlive(metadata.directory.endpoint(toAbort)))
        {
            String msg = String.format("Can't abort a %s operation for a node %s (%s) that is UP - run abortdecommission on that instance",
                                       kind, toAbort, metadata.directory.endpoint(toAbort));
            logger.info(msg);
            throw new IllegalStateException(msg);
        }
        ClusterMetadataService.instance().commit(new CancelInProgressSequence(toAbort));
    }
}

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Wait until the operation fails and the node enters the expected failed mode, then abort
  2. If the operation is still running, cancel it with the regular operation-specific cancel/stop mechanism instead of abort
  3. If the mode is stuck, check StorageService operation mode via nodetool and restart the node if the mode is stale

Example fix

// before
nodetool abortdecommission   // decommission still running
// after
// let it fail or stop it first:
nodetool decommissionwatch / cancel the running decommission,
confirm failed mode, then:
nodetool abortdecommission
Defensive patterns

Strategy: validation

Validate before calling

// only abort locally when the expected failed mode is active
String mode = StorageService.instance.operationMode();
if (!expectedFailedMode.equals(mode))
    throw new IllegalStateException("Cannot abort in mode " + mode);

Try / catch

try { abortLocal(kind); }
catch (IllegalStateException e) {
    if (e.getMessage().contains("unless it has failed")) { /* operation still running; wait or cancel */ }
    else throw e;
}

Prevention

When it happens

Trigger: Running abortdecommission/abortremove/abortmove on the node itself while StorageService.instance.operationMode() is not the expected failed mode (e.g. still NORMAL, DECOMMISSIONED already cleared, or LEAVING/moving in progress rather than failed).

Common situations: Operator tries to abort a decommission that is still actively running instead of waiting for it to fail; abort issued after clearTransientMode already reset the mode; wrong abort command for the operation type.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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