{"record":{"id":"75f0cd963505945c","repo":"apache/cassandra","slug":"error-occurred-during-user-defined-compaction","errorCode":null,"errorMessage":"Error occurred during user defined compaction","messagePattern":"Error occurred during user defined compaction","errorType":"console","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/Compact.java","lineNumber":88,"sourceCode":"        final boolean partitionKeyProvided = !partitionKey.isEmpty();\n        final boolean tokenProvided = startEndTokenProvided || partitionKeyProvided;\n        if (splitOutput && (userDefined || tokenProvided))\n        {\n            throw new RuntimeException(\"Invalid option combination: Can not use split-output here\");\n        }\n        if (userDefined && tokenProvided)\n        {\n            throw new RuntimeException(\"Invalid option combination: Can not provide tokens when using user-defined\");\n        }\n\n        if (userDefined)\n        {\n            try\n            {\n                String userDefinedFiles = String.join(\",\", args);\n                probe.forceUserDefinedCompaction(userDefinedFiles);\n            } catch (Exception e) {\n                throw new RuntimeException(\"Error occurred during user defined compaction\", e);\n            }\n            return;\n        }\n\n        List<String> keyspaces = parseOptionalKeyspace(args, probe);\n        String[] tableNames = parseOptionalTables(args);\n\n        for (String keyspace : keyspaces)\n        {\n            try\n            {\n                if (startEndTokenProvided)\n                {\n                    probe.forceKeyspaceCompactionForTokenRange(keyspace, startToken, endToken, tableNames);\n                }\n                else if (partitionKeyProvided)\n                {\n                    probe.forceKeyspaceCompactionForPartitionKey(keyspace, partitionKey, tableNames);","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/Compact.java#L70-L106","documentation":"When --user-defined compaction is requested, Compact calls probe.forceUserDefinedCompaction with the comma-joined SSTable file list; any Exception from the JMX call is wrapped in this RuntimeException. It indicates the node rejected or failed the user-defined compaction request.","triggerScenarios":"Supplying file names/paths that don't exist on the node, files already being compacted, malformed file list, or a remote failure while submitting the compaction via JMX.","commonSituations":"Listing SSTables that were already compacted away; wrong paths on a multi-node cluster (files are node-local); node under load rejecting new compactions.","solutions":["Verify each listed SSTable file exists on the target node (files are node-local paths).","Re-run listing only files currently present: `ls *-Data.db` / `nodetool listbackup`-style checks.","Check `nodetool compactionstats` for conflicting in-progress compactions.","Inspect the wrapped cause for the precise remote error."],"exampleFix":"// before\nnodetool compact --user-defined ks tbl data-ka-9-Data.db   # file already compacted\n// after\nnodetool compact --user-defined ks tbl data-ka-12-Data.db  # verify with ls first","handlingStrategy":"try-catch","validationCode":"for (String file : args) {\n    // files are node-local; verify via JMX or provisioning that each exists on the target node\n    if (!file.matches(\".+-Data\\.db\")) throw new IllegalArgumentException(\"Not an SSTable data file: \" + file);\n}","typeGuard":null,"tryCatchPattern":"try { probe.forceUserDefinedCompaction(files); }\ncatch (RuntimeException e) {\n    log(\"User-defined compaction failed: \" + e.getCause());\n    // check compactionstats and file existence before retry\n}","preventionTips":["Verify SSTable filenames still exist right before submission (major compaction can remove them).","Run user-defined compaction per node with node-local paths.","Avoid requesting compaction of files already in an active compaction (`nodetool compactionstats`).","Use the wrapped cause to distinguish bad-file-list from transport failures."],"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"}