{"record":{"id":"06ac03339cef02af","repo":"apache/cassandra","slug":"error-occurred-during-compaction","errorCode":null,"errorMessage":"Error occurred during compaction","messagePattern":"Error occurred during compaction","errorType":"console","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/Compact.java","lineNumber":117,"sourceCode":"            {\n                if (startEndTokenProvided)\n                {\n                    probe.forceKeyspaceCompactionForTokenRange(keyspace, startToken, endToken, tableNames);\n                }\n                else if (partitionKeyProvided)\n                {\n                    probe.forceKeyspaceCompactionForPartitionKey(keyspace, partitionKey, tableNames);\n                }\n                else\n                {\n                    if (parallelism != null)\n                        probe.forceKeyspaceCompaction(splitOutput, parallelism, keyspace, tableNames);\n                    else // avoid referring to the new method to work with older versions\n                        probe.forceKeyspaceCompaction(splitOutput, keyspace, tableNames);\n                }\n            } catch (Exception e)\n            {\n                throw new RuntimeException(\"Error occurred during compaction\", e);\n            }\n        }\n    }\n}\n","sourceCodeStart":99,"sourceCodeEnd":122,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/Compact.java#L99-L122","documentation":"After option validation, Compact submits keyspace/table compaction via probe.forceKeyspaceCompaction over JMX; any Exception is wrapped as 'Error occurred during compaction'. It signals the remote node failed to start or complete the compaction request.","triggerScenarios":"`nodetool compact <keyspace> [tables]` when the node has insufficient disk space, ongoing repairs/compactions conflict, the keyspace/table exists but compaction is disallowed, or JMX call fails mid-operation.","commonSituations":"Disk nearly full (compaction needs free space for merged SSTables); running during a repair; compacting a table with pending validation; nodetool targeting a degraded node.","solutions":["Check node disk space and `nodetool compactionstats` before retrying.","Ensure no concurrent repair or major operations on the tables.","Retry the compaction on each node individually to isolate the failing node.","Inspect the 'Caused by' of this RuntimeException for the remote error detail."],"exampleFix":"// before\nnodetool compact ks  # fails with 95% disk usage\n// after\ndf -h; nodetool compactionstats  # free space / check conflicts, then retry\nnodetool compact ks","handlingStrategy":"try-catch","validationCode":"// preflight checks\nassertFreeDisk(node, requiredBytes);\nassertNoActiveRepair(node);  // nodetool netstats / repair_admin\nassertCompactionQueueNotSaturated(node); // nodetool compactionstats","typeGuard":null,"tryCatchPattern":"try { probe.forceKeyspaceCompaction(splitOutput, parallelism, ks, tables); }\ncatch (RuntimeException e) {\n    log.warn(\"Compaction failed: \" + e.getCause());\n    // free disk / resolve conflicts, then retry with backoff\n}","preventionTips":["Keep free disk headroom (Cassandra recommends leaving room for compaction spikes).","Avoid overlapping major compactions with repairs.","Run compaction during low-write windows.","Check the 'Caused by' for node-specific reasons before retrying."],"tags":["nodetool","compaction","jmx"],"backgroundTag":"api-request-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}