{"record":{"id":"dcedde79c2672ea3","repo":"apache/cassandra","slug":"when-specifying-the-table-for-a-snapshot-you-must","errorCode":null,"errorMessage":"When specifying the table for a snapshot, you must specify one and only one keyspace","messagePattern":"When specifying the table for a snapshot, you must specify one and only one keyspace","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/NodeProbe.java","lineNumber":976,"sourceCode":"    {\n        snapshotProxy.setSnapshotLinksPerSecond(throttle);\n    }\n\n    /**\n     * Take a snapshot of all the keyspaces, optionally specifying only a specific column family.\n     *\n     * @param snapshotName the name of the snapshot.\n     * @param table the table to snapshot or all on null\n     * @param options Options (skipFlush for now)\n     * @param keyspaces the keyspaces to snapshot\n     */\n    public void takeSnapshot(String snapshotName, String table, Map<String, String> options, String... keyspaces) throws IOException\n    {\n        if (table != null)\n        {\n            if (keyspaces.length != 1)\n            {\n                throw new IOException(\"When specifying the table for a snapshot, you must specify one and only one keyspace\");\n            }\n\n            snapshotProxy.takeSnapshot(snapshotName, options, keyspaces[0] + \".\" + table);\n        }\n        else\n            snapshotProxy.takeSnapshot(snapshotName, options, keyspaces);\n    }\n\n    /**\n     * Take a snapshot of all column family from different keyspaces.\n     *\n     * @param snapshotName\n     *            the name of the snapshot.\n     * @param options\n     *            Options (skipFlush for now)\n     * @param tableList\n     *            list of columnfamily from different keyspace in the form of ks1.cf1 ks2.cf2\n     */","sourceCodeStart":958,"sourceCodeEnd":994,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/NodeProbe.java#L958-L994","documentation":"IllegalArgumentException from NodeProbe.takeSnapshot when a table argument is given but the keyspace list does not contain exactly one keyspace. Snapshots of a single table require unambiguous keyspace scope, so calls with a table plus zero or multiple keyspaces are rejected before contacting the snapshot MBean.","triggerScenarios":"nodetool snapshot -cf table (or NodeProbe.takeSnapshot with a non-null table) passing zero or multiple keyspaces — e.g. 'nodetool snapshot -cf users' without a keyspace, or with two or more keyspaces.","commonSituations":"Scripting snapshot calls with a table but forgetting the keyspace; assuming a table filter can span keyspaces in one command.","solutions":["Pass exactly one keyspace together with the table: nodetool snapshot -ks keyspace1 -cf users","If you need the same table in many keyspaces, run one snapshot per keyspace","Omit -cf if you intend to snapshot entire keyspaces"],"exampleFix":"// before\nnodetool snapshot -cf users\n// after\nnodetool snapshot -ks keyspace1 -cf users","handlingStrategy":"validation","validationCode":"if (table != null && (keyspaces == null || keyspaces.length != 1))\n    throw new IllegalArgumentException(\"table requires exactly one keyspace\");","typeGuard":null,"tryCatchPattern":"try {\n    probe.takeSnapshot(snapshotName, table, options, keyspaces);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"one and only one keyspace\"))\n        System.err.println(\"Pass exactly one keyspace when using -cf\");\n    else throw e;\n}","preventionTips":["Always pair -cf with exactly one -ks value","Validate script arguments before invoking nodetool","Loop per-keyspace when snapshotting a table across many keyspaces"],"tags":["snapshot","cli","validation"],"backgroundTag":"missing-required-argument","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"}