apache/cassandra · error · RuntimeException

Unable to cancel in-progress compactions for {keyspace}.{tab

Error message

Unable to cancel in-progress compactions for {keyspace}.{tableName}. Usually retrying will work.

What it means

Thrown by StorageService's unrepaired-SSTable handling when the anticompaction executor (ColumnFamilyStore.markCompacting via the anti-compaction operation) returns null, meaning in-progress compactions could not be cancelled so the SSTables could not be marked. The message notes a retry usually works.

Source

Thrown at src/java/org/apache/cassandra/service/StorageService.java:5906

        }

        // only select SSTables that are unrepaired when repaired is true and vice versa
        Predicate<SSTableReader> predicate = sst -> repaired != sst.isRepaired();

        // mutate SSTables
        long repairedAt = !repaired ? 0 : currentTimeMillis();
        List<String> sstablesTouched = new ArrayList<>();
        for (String tableName : tableNames)
        {
            ColumnFamilyStore table = tables.get(tableName);
            Set<SSTableReader> result = table.runWithCompactionsDisabled(() -> {
                Set<SSTableReader> sstables = table.getLiveSSTables().stream().filter(predicate).collect(Collectors.toSet());
                if (!preview)
                    table.getCompactionStrategyManager().mutateRepaired(sstables, repairedAt, null, false);
                return sstables;
            }, predicate, OperationType.ANTICOMPACTION, true, false, true);
            if (result == null)
                throw new RuntimeException("Unable to cancel in-progress compactions for " + keyspace + '.' + tableName + ". Usually retrying will work.");
            sstablesTouched.addAll(result.stream().map(sst -> sst.descriptor.baseFile().name()).collect(Collectors.toList()));
        }
        return sstablesTouched;
    }

    @Override
    public TabularData getOrphanedCompressionDictionaries()
    {
        List<LightweightCompressionDictionary> dicts = SystemDistributedKeyspace.retrieveOrphanedLightweightCompressionDictionaries();
        TabularDataSupport tabularData = new TabularDataSupport(CompressionDictionaryDetailsTabularData.TABULAR_TYPE);

        if (dicts.isEmpty())
            return tabularData;

        for (LightweightCompressionDictionary dict : dicts)
            tabularData.put(CompressionDictionaryDetailsTabularData.fromLightweightCompressionDictionary(dict));

        return tabularData;

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Retry the operation after a short wait (the error is usually transient).
  2. Temporarily disable compaction on the table (`nodetool disableautocompaction`) or wait for ongoing compactions to finish, then retry.
  3. Check `nodetool compactionstats` for competing compactions/repairs and stop conflicting operations first.
Defensive patterns

Strategy: retry

Validate before calling

// Check for active compactions before calling
// Map<String, String> active = ManagementFactory.getPlatformMBeanServer().invoke(...compactionstats...)

Try / catch

try { ss.unrepairedSSTables(ks, tables); }
catch (RuntimeException e) { if (e.getMessage().contains("Unable to cancel in-progress compactions")) { sleep(backoff); retry(); } else throw e; }

Prevention

When it happens

Trigger: Calling the mark-unrepaired / cancel-compactions JMX operation while the target table's SSTables are locked by an ongoing compaction, streaming, or repair; markCompacting returns null because lifecycle transactions conflict.

Common situations: Running repair-anticompaction cleanup while continuous compaction is active; concurrent repair sessions; heavy write load keeping compaction busy.

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