{"record":{"id":"e193b684ea1799dd","repo":"apache/cassandra","slug":"invalid-target-size-for-sstables-must-be-0-got","errorCode":null,"errorMessage":"Invalid target size for SSTables, must be > 0 (got: %s)","messagePattern":"Invalid target size for SSTables, must be > 0 \\(got: (.+?)\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compaction/SSTableSplitter.java","lineNumber":55,"sourceCode":"        this.task = new SplittingCompactionTask(cfs, transaction, sstableSizeInMB);\n    }\n\n    public void split()\n    {\n        task.execute(ActiveCompactionsTracker.NOOP);\n    }\n\n    public static class SplittingCompactionTask extends CompactionTask\n    {\n        private final int sstableSizeInMiB;\n\n        public SplittingCompactionTask(ColumnFamilyStore cfs, ILifecycleTransaction transaction, int sstableSizeInMB)\n        {\n            super(cfs, transaction, CompactionManager.NO_GC, false);\n            this.sstableSizeInMiB = sstableSizeInMB;\n\n            if (sstableSizeInMB <= 0)\n                throw new IllegalArgumentException(\"Invalid target size for SSTables, must be > 0 (got: \" + sstableSizeInMB + \")\");\n        }\n\n        @Override\n        protected CompactionController getCompactionController(Set<SSTableReader> toCompact, long gcBefore)\n        {\n            return new SplitController(cfs);\n        }\n\n        @Override\n        public CompactionAwareWriter getCompactionAwareWriter(ColumnFamilyStore cfs,\n                                                              Directories directories,\n                                                              ILifecycleTransaction txn,\n                                                              Set<SSTableReader> nonExpiredSSTables)\n        {\n            return new MaxSSTableSizeWriter(cfs, directories, txn, nonExpiredSSTables, sstableSizeInMiB * 1024L * 1024L, 0, false);\n        }\n\n        @Override","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compaction/SSTableSplitter.java#L37-L73","documentation":"IllegalArgumentException thrown by the SplittingCompactionTask constructor when the target SSTable size given to nodetool's sstablesplit / SSTableSplitter is zero or negative. The splitter compacts SSTables down to a target size, so a non-positive target is meaningless and the task refuses to run. This is a programming/CLI argument validation error, not a runtime state issue.","triggerScenarios":"Calling ColumnFamilyStore.sstableSplit or the SSTableSplitter API with sstableSizeInMB <= 0 (e.g. 0 or a negative int), typically via a negative value passed to the nodetool sstable_splitter style invocation or an internal caller that computes the size from uninitialized/config data.","commonSituations":"Administrators scripting nodetool pass a computed size that evaluates to 0 or negative (unit-conversion bug, empty config value parsed as 0); tooling wraps the JMX operation and passes a placeholder value before reading real config.","solutions":["Pass a positive target size in MiB (e.g. 50 or 100) to the split operation.","Check any script/config that computes sstableSizeInMB for unit conversion or empty-string-to-0 parsing bugs.","Add a caller-side check (size > 0) before invoking the split API to fail fast with a clearer message."],"exampleFix":"// before\nint sizeInMb = Integer.parseInt(configValue); // \"\" -> NumberFormatException, \"0\" -> 0\nnew SSTableSplitter(cfs, txn, sizeInMb);\n// after\nint sizeInMb = Integer.parseInt(configValue.trim());\nif (sizeInMb <= 0) throw new IllegalArgumentException(\"sstable size must be > 0, got: \" + configValue);\nnew SSTableSplitter(cfs, txn, sizeInMb);","handlingStrategy":"validation","validationCode":"if (sstableSizeInMB <= 0) throw new IllegalArgumentException(\"sstableSizeInMB must be > 0, got: \" + sstableSizeInMB);","typeGuard":null,"tryCatchPattern":"try { store.sstableSplit(sizeInMb); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"Invalid target size\")) { /* fix size and retry with a positive value */ } else throw e; }","preventionTips":["Always pass an explicitly positive MiB value; never forward unparsed/empty config values.","Clamp computed sizes: Math.max(1, computedSizeMb).","Add an assertion or bean-validation check at the API boundary before invoking the split."],"tags":["compaction","invalid-argument","cli-argument"],"backgroundTag":"invalid-argument-value","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"}