{"record":{"id":"f4fef877992772bc","repo":"apache/cassandra","slug":"unable-to-cancel-in-progress-compactions-for-keys","errorCode":null,"errorMessage":"Unable to cancel in-progress compactions for {keyspace}.{tableName}. Usually retrying will work.","messagePattern":"Unable to cancel in-progress compactions for (.+?)\\.(.+?)\\. Usually retrying will work\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageService.java","lineNumber":5906,"sourceCode":"        }\n\n        // only select SSTables that are unrepaired when repaired is true and vice versa\n        Predicate<SSTableReader> predicate = sst -> repaired != sst.isRepaired();\n\n        // mutate SSTables\n        long repairedAt = !repaired ? 0 : currentTimeMillis();\n        List<String> sstablesTouched = new ArrayList<>();\n        for (String tableName : tableNames)\n        {\n            ColumnFamilyStore table = tables.get(tableName);\n            Set<SSTableReader> result = table.runWithCompactionsDisabled(() -> {\n                Set<SSTableReader> sstables = table.getLiveSSTables().stream().filter(predicate).collect(Collectors.toSet());\n                if (!preview)\n                    table.getCompactionStrategyManager().mutateRepaired(sstables, repairedAt, null, false);\n                return sstables;\n            }, predicate, OperationType.ANTICOMPACTION, true, false, true);\n            if (result == null)\n                throw new RuntimeException(\"Unable to cancel in-progress compactions for \" + keyspace + '.' + tableName + \". Usually retrying will work.\");\n            sstablesTouched.addAll(result.stream().map(sst -> sst.descriptor.baseFile().name()).collect(Collectors.toList()));\n        }\n        return sstablesTouched;\n    }\n\n    @Override\n    public TabularData getOrphanedCompressionDictionaries()\n    {\n        List<LightweightCompressionDictionary> dicts = SystemDistributedKeyspace.retrieveOrphanedLightweightCompressionDictionaries();\n        TabularDataSupport tabularData = new TabularDataSupport(CompressionDictionaryDetailsTabularData.TABULAR_TYPE);\n\n        if (dicts.isEmpty())\n            return tabularData;\n\n        for (LightweightCompressionDictionary dict : dicts)\n            tabularData.put(CompressionDictionaryDetailsTabularData.fromLightweightCompressionDictionary(dict));\n\n        return tabularData;","sourceCodeStart":5888,"sourceCodeEnd":5924,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageService.java#L5888-L5924","documentation":"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.","triggerScenarios":"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.","commonSituations":"Running repair-anticompaction cleanup while continuous compaction is active; concurrent repair sessions; heavy write load keeping compaction busy.","solutions":["Retry the operation after a short wait (the error is usually transient).","Temporarily disable compaction on the table (`nodetool disableautocompaction`) or wait for ongoing compactions to finish, then retry.","Check `nodetool compactionstats` for competing compactions/repairs and stop conflicting operations first."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Check for active compactions before calling\n// Map<String, String> active = ManagementFactory.getPlatformMBeanServer().invoke(...compactionstats...)","typeGuard":null,"tryCatchPattern":"try { ss.unrepairedSSTables(ks, tables); }\ncatch (RuntimeException e) { if (e.getMessage().contains(\"Unable to cancel in-progress compactions\")) { sleep(backoff); retry(); } else throw e; }","preventionTips":["Check nodetool compactionstats for competing work first","Retry with backoff — the error is usually transient","Temporarily disable autocompaction on the table during the operation","Avoid running concurrent repairs on the same table"],"tags":["cassandra","compaction","sstable","retryable","repair"],"backgroundTag":"invalid-state-transition","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}