{"record":{"id":"ef518a69c269272c","repo":"apache/cassandra","slug":"all-sstables-must-be-part-of-the-same-keyspace","errorCode":null,"errorMessage":"All sstables must be part of the same keyspace","messagePattern":"All sstables must be part of the same keyspace","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/StandaloneSplitter.java","lineNumber":96,"sourceCode":"            Map<Descriptor, Set<Component>> parsedFilenames = new HashMap<Descriptor, Set<Component>>();\n            for (String filename : options.filenames)\n            {\n                File file = new File(filename);\n                if (!file.exists()) {\n                    System.out.println(\"Skipping inexisting file \" + file);\n                    continue;\n                }\n\n                Descriptor desc = SSTable.tryDescriptorFromFile(file);\n                if (desc == null) {\n                    System.out.println(\"Skipping non sstable file \" + file);\n                    continue;\n                }\n\n                if (ksName == null)\n                    ksName = desc.ksname;\n                else if (!ksName.equals(desc.ksname))\n                    throw new IllegalArgumentException(\"All sstables must be part of the same keyspace\");\n\n                if (cfName == null)\n                    cfName = desc.cfname;\n                else if (!cfName.equals(desc.cfname))\n                    throw new IllegalArgumentException(\"All sstables must be part of the same table\");\n\n                parsedFilenames.put(desc, desc.getComponents(Collections.emptySet(), desc.getFormat().batchComponents()));\n            }\n\n            if (ksName == null || cfName == null)\n            {\n                System.err.println(\"No valid sstables to split\");\n                System.exit(1);\n            }\n\n            // Do not load sstables since they might be broken\n            Keyspace keyspace = Keyspace.openWithoutSSTables(ksName);\n            ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/StandaloneSplitter.java#L78-L114","documentation":"StandaloneSplitter.main groups the SSTables it was given by descriptor. If a later SSTable's descriptor keyspace name differs from the first one's, it throws IllegalArgumentException: the splitter operates on one table at a time, so mixing keyspaces is invalid input.","triggerScenarios":"Passing multiple --sstables arguments (or a glob) whose Descriptor.ksname values differ; the mismatch is detected while building parsedFilenames.","commonSituations":"Shell glob like *.db expanding across several keyspaces' directories; copy-pasting sstable paths from different tables; scripting that collects all sstables in a snapshot directory.","solutions":["Run the splitter once per table, passing only SSTables of a single keyspace","Fix the glob/path list to exclude SSTables from other keyspaces","Check each file's Descriptor (embedded in the filename) before invoking"],"exampleFix":"// before\nStandaloneSplitter data/*/users-*.db  # spans keyspaces\n// after\nStandaloneSplitter data/ks1/users-*.db","handlingStrategy":"validation","validationCode":"Set<String> kss = files.stream()\n    .map(f -> Descriptor.fromFilename(f).ksname)\n    .collect(Collectors.toSet());\nif (kss.size() != 1) throw new IllegalArgumentException(\"All sstables must be part of the same keyspace\");","typeGuard":null,"tryCatchPattern":"try { StandaloneSplitter.main(args); }\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"same keyspace\")) {\n        // re-group inputs per keyspace and retry per table\n    } else throw e;\n}","preventionTips":["Avoid broad globs like data/*/*.db; scope to one table directory","Derive sstable paths from a single table's snapshot","Parse the Descriptor from filenames to group inputs beforehand"],"tags":["cli","sstables","offline-tools"],"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"}